repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
diecode/KillerMoney
src/net/diecode/killermoney/functions/CCommandHandler.java
// Path: src/net/diecode/killermoney/enums/KMPermission.java // public enum KMPermission { // // ADMIN("admin"), // MONEY_MULTIPLIER("money.multiplier"), // // LIMIT_MONEY_MULTIPLIER("moneylimit.multiplier"), // //LIMIT_ITEM_MULTIPLIER("itemlimit.multiplier"), // //LIMIT_COMMAND_MULTIPLIER("commandlimit.multiplier"), // // BYPASS_MONEY_LIMIT("bypass.moneylimit"), // BYPASS_ITEM_LIMIT("bypass.itemlimit"), // BYPASS_COMMAND_LIMIT("bypass.commandlimit"), // BYPASS_MONEY_LIMIT_CASH_TRANSFER("bypass.cashtransferlimit"); // // private String perm; // // KMPermission(String perm) { // this.perm = perm; // } // // public String get() { // return "km." + perm; // } // // } // // Path: src/net/diecode/killermoney/enums/RunMethod.java // public enum RunMethod { // // ALL, RANDOM // // } // // Path: src/net/diecode/killermoney/events/KMCCommandExecutionEvent.java // public class KMCCommandExecutionEvent extends Event implements Cancellable { // // private static final HandlerList handlers = new HandlerList(); // // private CCommand cCommand; // private Player killer; // private LivingEntity victim; // private boolean cancelled; // // public KMCCommandExecutionEvent(CCommand cCommand, Player killer, LivingEntity victim) { // this.cCommand = cCommand; // this.killer = killer; // this.victim = victim; // } // // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public CCommand getCCommand() { // return cCommand; // } // // public Player getKiller() { // return killer; // } // // public LivingEntity getVictim() { // return victim; // } // // @Override // public boolean isCancelled() { // return cancelled; // } // // @Override // public void setCancelled(boolean cancelled) { // this.cancelled = cancelled; // } // } // // Path: src/net/diecode/killermoney/objects/CCommand.java // public class CCommand { // // private String command; // private String permission; // private double chance; // private int limit; // private HashMap<UUID, Integer> limitCounter = new HashMap<UUID, Integer>(); // // public CCommand(String command, String permission, double chance, int limit) { // this.command = command; // this.permission = permission; // this.chance = chance; // this.limit = limit; // } // // public String getCommand() { // return command; // } // // public String getPermission() { // return permission; // } // // public double getChance() { // return chance; // } // // public int getLimit() { // return limit; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public HashMap<UUID, Integer> getLimitCounter() { // return limitCounter; // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // if (current >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // limitCounter.put(uuid, current + 1); // } else { // limitCounter.put(uuid, 1); // } // } // // public int getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return 0; // } // } // // Path: src/net/diecode/killermoney/objects/CCommandProperties.java // public class CCommandProperties { // // private RunMethod runMethod; // private ArrayList<CCommand> cCommands; // private boolean enabled; // // public CCommandProperties(RunMethod runMethod, ArrayList<CCommand> cCommands, boolean enabled) { // this.runMethod = runMethod; // this.cCommands = cCommands; // this.enabled = enabled; // } // // public RunMethod getRunMethod() { // return runMethod; // } // // public ArrayList<CCommand> getCCommands() { // return cCommands; // } // // public boolean isEnabled() { // return enabled; // } // }
import net.diecode.killermoney.enums.KMPermission; import net.diecode.killermoney.enums.RunMethod; import net.diecode.killermoney.events.KMCCommandExecutionEvent; import net.diecode.killermoney.objects.CCommand; import net.diecode.killermoney.objects.CCommandProperties; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import java.util.ArrayList; import java.util.Random;
package net.diecode.killermoney.functions; public class CCommandHandler implements Listener { @EventHandler (priority = EventPriority.LOW)
// Path: src/net/diecode/killermoney/enums/KMPermission.java // public enum KMPermission { // // ADMIN("admin"), // MONEY_MULTIPLIER("money.multiplier"), // // LIMIT_MONEY_MULTIPLIER("moneylimit.multiplier"), // //LIMIT_ITEM_MULTIPLIER("itemlimit.multiplier"), // //LIMIT_COMMAND_MULTIPLIER("commandlimit.multiplier"), // // BYPASS_MONEY_LIMIT("bypass.moneylimit"), // BYPASS_ITEM_LIMIT("bypass.itemlimit"), // BYPASS_COMMAND_LIMIT("bypass.commandlimit"), // BYPASS_MONEY_LIMIT_CASH_TRANSFER("bypass.cashtransferlimit"); // // private String perm; // // KMPermission(String perm) { // this.perm = perm; // } // // public String get() { // return "km." + perm; // } // // } // // Path: src/net/diecode/killermoney/enums/RunMethod.java // public enum RunMethod { // // ALL, RANDOM // // } // // Path: src/net/diecode/killermoney/events/KMCCommandExecutionEvent.java // public class KMCCommandExecutionEvent extends Event implements Cancellable { // // private static final HandlerList handlers = new HandlerList(); // // private CCommand cCommand; // private Player killer; // private LivingEntity victim; // private boolean cancelled; // // public KMCCommandExecutionEvent(CCommand cCommand, Player killer, LivingEntity victim) { // this.cCommand = cCommand; // this.killer = killer; // this.victim = victim; // } // // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public CCommand getCCommand() { // return cCommand; // } // // public Player getKiller() { // return killer; // } // // public LivingEntity getVictim() { // return victim; // } // // @Override // public boolean isCancelled() { // return cancelled; // } // // @Override // public void setCancelled(boolean cancelled) { // this.cancelled = cancelled; // } // } // // Path: src/net/diecode/killermoney/objects/CCommand.java // public class CCommand { // // private String command; // private String permission; // private double chance; // private int limit; // private HashMap<UUID, Integer> limitCounter = new HashMap<UUID, Integer>(); // // public CCommand(String command, String permission, double chance, int limit) { // this.command = command; // this.permission = permission; // this.chance = chance; // this.limit = limit; // } // // public String getCommand() { // return command; // } // // public String getPermission() { // return permission; // } // // public double getChance() { // return chance; // } // // public int getLimit() { // return limit; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public HashMap<UUID, Integer> getLimitCounter() { // return limitCounter; // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // if (current >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // limitCounter.put(uuid, current + 1); // } else { // limitCounter.put(uuid, 1); // } // } // // public int getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return 0; // } // } // // Path: src/net/diecode/killermoney/objects/CCommandProperties.java // public class CCommandProperties { // // private RunMethod runMethod; // private ArrayList<CCommand> cCommands; // private boolean enabled; // // public CCommandProperties(RunMethod runMethod, ArrayList<CCommand> cCommands, boolean enabled) { // this.runMethod = runMethod; // this.cCommands = cCommands; // this.enabled = enabled; // } // // public RunMethod getRunMethod() { // return runMethod; // } // // public ArrayList<CCommand> getCCommands() { // return cCommands; // } // // public boolean isEnabled() { // return enabled; // } // } // Path: src/net/diecode/killermoney/functions/CCommandHandler.java import net.diecode.killermoney.enums.KMPermission; import net.diecode.killermoney.enums.RunMethod; import net.diecode.killermoney.events.KMCCommandExecutionEvent; import net.diecode.killermoney.objects.CCommand; import net.diecode.killermoney.objects.CCommandProperties; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import java.util.ArrayList; import java.util.Random; package net.diecode.killermoney.functions; public class CCommandHandler implements Listener { @EventHandler (priority = EventPriority.LOW)
public void onCustomCommand(KMCCommandExecutionEvent e) {
diecode/KillerMoney
src/net/diecode/killermoney/functions/CCommandHandler.java
// Path: src/net/diecode/killermoney/enums/KMPermission.java // public enum KMPermission { // // ADMIN("admin"), // MONEY_MULTIPLIER("money.multiplier"), // // LIMIT_MONEY_MULTIPLIER("moneylimit.multiplier"), // //LIMIT_ITEM_MULTIPLIER("itemlimit.multiplier"), // //LIMIT_COMMAND_MULTIPLIER("commandlimit.multiplier"), // // BYPASS_MONEY_LIMIT("bypass.moneylimit"), // BYPASS_ITEM_LIMIT("bypass.itemlimit"), // BYPASS_COMMAND_LIMIT("bypass.commandlimit"), // BYPASS_MONEY_LIMIT_CASH_TRANSFER("bypass.cashtransferlimit"); // // private String perm; // // KMPermission(String perm) { // this.perm = perm; // } // // public String get() { // return "km." + perm; // } // // } // // Path: src/net/diecode/killermoney/enums/RunMethod.java // public enum RunMethod { // // ALL, RANDOM // // } // // Path: src/net/diecode/killermoney/events/KMCCommandExecutionEvent.java // public class KMCCommandExecutionEvent extends Event implements Cancellable { // // private static final HandlerList handlers = new HandlerList(); // // private CCommand cCommand; // private Player killer; // private LivingEntity victim; // private boolean cancelled; // // public KMCCommandExecutionEvent(CCommand cCommand, Player killer, LivingEntity victim) { // this.cCommand = cCommand; // this.killer = killer; // this.victim = victim; // } // // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public CCommand getCCommand() { // return cCommand; // } // // public Player getKiller() { // return killer; // } // // public LivingEntity getVictim() { // return victim; // } // // @Override // public boolean isCancelled() { // return cancelled; // } // // @Override // public void setCancelled(boolean cancelled) { // this.cancelled = cancelled; // } // } // // Path: src/net/diecode/killermoney/objects/CCommand.java // public class CCommand { // // private String command; // private String permission; // private double chance; // private int limit; // private HashMap<UUID, Integer> limitCounter = new HashMap<UUID, Integer>(); // // public CCommand(String command, String permission, double chance, int limit) { // this.command = command; // this.permission = permission; // this.chance = chance; // this.limit = limit; // } // // public String getCommand() { // return command; // } // // public String getPermission() { // return permission; // } // // public double getChance() { // return chance; // } // // public int getLimit() { // return limit; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public HashMap<UUID, Integer> getLimitCounter() { // return limitCounter; // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // if (current >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // limitCounter.put(uuid, current + 1); // } else { // limitCounter.put(uuid, 1); // } // } // // public int getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return 0; // } // } // // Path: src/net/diecode/killermoney/objects/CCommandProperties.java // public class CCommandProperties { // // private RunMethod runMethod; // private ArrayList<CCommand> cCommands; // private boolean enabled; // // public CCommandProperties(RunMethod runMethod, ArrayList<CCommand> cCommands, boolean enabled) { // this.runMethod = runMethod; // this.cCommands = cCommands; // this.enabled = enabled; // } // // public RunMethod getRunMethod() { // return runMethod; // } // // public ArrayList<CCommand> getCCommands() { // return cCommands; // } // // public boolean isEnabled() { // return enabled; // } // }
import net.diecode.killermoney.enums.KMPermission; import net.diecode.killermoney.enums.RunMethod; import net.diecode.killermoney.events.KMCCommandExecutionEvent; import net.diecode.killermoney.objects.CCommand; import net.diecode.killermoney.objects.CCommandProperties; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import java.util.ArrayList; import java.util.Random;
package net.diecode.killermoney.functions; public class CCommandHandler implements Listener { @EventHandler (priority = EventPriority.LOW) public void onCustomCommand(KMCCommandExecutionEvent e) { if (e.isCancelled()) { return; } String command = e.getCCommand().getCommand(); if (command != null) { command = command.replace("{player}", e.getKiller().getName()); e.getCCommand().increaseLimitCounter(e.getKiller().getUniqueId()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); } }
// Path: src/net/diecode/killermoney/enums/KMPermission.java // public enum KMPermission { // // ADMIN("admin"), // MONEY_MULTIPLIER("money.multiplier"), // // LIMIT_MONEY_MULTIPLIER("moneylimit.multiplier"), // //LIMIT_ITEM_MULTIPLIER("itemlimit.multiplier"), // //LIMIT_COMMAND_MULTIPLIER("commandlimit.multiplier"), // // BYPASS_MONEY_LIMIT("bypass.moneylimit"), // BYPASS_ITEM_LIMIT("bypass.itemlimit"), // BYPASS_COMMAND_LIMIT("bypass.commandlimit"), // BYPASS_MONEY_LIMIT_CASH_TRANSFER("bypass.cashtransferlimit"); // // private String perm; // // KMPermission(String perm) { // this.perm = perm; // } // // public String get() { // return "km." + perm; // } // // } // // Path: src/net/diecode/killermoney/enums/RunMethod.java // public enum RunMethod { // // ALL, RANDOM // // } // // Path: src/net/diecode/killermoney/events/KMCCommandExecutionEvent.java // public class KMCCommandExecutionEvent extends Event implements Cancellable { // // private static final HandlerList handlers = new HandlerList(); // // private CCommand cCommand; // private Player killer; // private LivingEntity victim; // private boolean cancelled; // // public KMCCommandExecutionEvent(CCommand cCommand, Player killer, LivingEntity victim) { // this.cCommand = cCommand; // this.killer = killer; // this.victim = victim; // } // // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public CCommand getCCommand() { // return cCommand; // } // // public Player getKiller() { // return killer; // } // // public LivingEntity getVictim() { // return victim; // } // // @Override // public boolean isCancelled() { // return cancelled; // } // // @Override // public void setCancelled(boolean cancelled) { // this.cancelled = cancelled; // } // } // // Path: src/net/diecode/killermoney/objects/CCommand.java // public class CCommand { // // private String command; // private String permission; // private double chance; // private int limit; // private HashMap<UUID, Integer> limitCounter = new HashMap<UUID, Integer>(); // // public CCommand(String command, String permission, double chance, int limit) { // this.command = command; // this.permission = permission; // this.chance = chance; // this.limit = limit; // } // // public String getCommand() { // return command; // } // // public String getPermission() { // return permission; // } // // public double getChance() { // return chance; // } // // public int getLimit() { // return limit; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public HashMap<UUID, Integer> getLimitCounter() { // return limitCounter; // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // if (current >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // limitCounter.put(uuid, current + 1); // } else { // limitCounter.put(uuid, 1); // } // } // // public int getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return 0; // } // } // // Path: src/net/diecode/killermoney/objects/CCommandProperties.java // public class CCommandProperties { // // private RunMethod runMethod; // private ArrayList<CCommand> cCommands; // private boolean enabled; // // public CCommandProperties(RunMethod runMethod, ArrayList<CCommand> cCommands, boolean enabled) { // this.runMethod = runMethod; // this.cCommands = cCommands; // this.enabled = enabled; // } // // public RunMethod getRunMethod() { // return runMethod; // } // // public ArrayList<CCommand> getCCommands() { // return cCommands; // } // // public boolean isEnabled() { // return enabled; // } // } // Path: src/net/diecode/killermoney/functions/CCommandHandler.java import net.diecode.killermoney.enums.KMPermission; import net.diecode.killermoney.enums.RunMethod; import net.diecode.killermoney.events.KMCCommandExecutionEvent; import net.diecode.killermoney.objects.CCommand; import net.diecode.killermoney.objects.CCommandProperties; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import java.util.ArrayList; import java.util.Random; package net.diecode.killermoney.functions; public class CCommandHandler implements Listener { @EventHandler (priority = EventPriority.LOW) public void onCustomCommand(KMCCommandExecutionEvent e) { if (e.isCancelled()) { return; } String command = e.getCCommand().getCommand(); if (command != null) { command = command.replace("{player}", e.getKiller().getName()); e.getCCommand().increaseLimitCounter(e.getKiller().getUniqueId()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); } }
public static void process(CCommandProperties cCommandProperties, LivingEntity livingEntity, Player killer) {
diecode/KillerMoney
src/net/diecode/killermoney/functions/CCommandHandler.java
// Path: src/net/diecode/killermoney/enums/KMPermission.java // public enum KMPermission { // // ADMIN("admin"), // MONEY_MULTIPLIER("money.multiplier"), // // LIMIT_MONEY_MULTIPLIER("moneylimit.multiplier"), // //LIMIT_ITEM_MULTIPLIER("itemlimit.multiplier"), // //LIMIT_COMMAND_MULTIPLIER("commandlimit.multiplier"), // // BYPASS_MONEY_LIMIT("bypass.moneylimit"), // BYPASS_ITEM_LIMIT("bypass.itemlimit"), // BYPASS_COMMAND_LIMIT("bypass.commandlimit"), // BYPASS_MONEY_LIMIT_CASH_TRANSFER("bypass.cashtransferlimit"); // // private String perm; // // KMPermission(String perm) { // this.perm = perm; // } // // public String get() { // return "km." + perm; // } // // } // // Path: src/net/diecode/killermoney/enums/RunMethod.java // public enum RunMethod { // // ALL, RANDOM // // } // // Path: src/net/diecode/killermoney/events/KMCCommandExecutionEvent.java // public class KMCCommandExecutionEvent extends Event implements Cancellable { // // private static final HandlerList handlers = new HandlerList(); // // private CCommand cCommand; // private Player killer; // private LivingEntity victim; // private boolean cancelled; // // public KMCCommandExecutionEvent(CCommand cCommand, Player killer, LivingEntity victim) { // this.cCommand = cCommand; // this.killer = killer; // this.victim = victim; // } // // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public CCommand getCCommand() { // return cCommand; // } // // public Player getKiller() { // return killer; // } // // public LivingEntity getVictim() { // return victim; // } // // @Override // public boolean isCancelled() { // return cancelled; // } // // @Override // public void setCancelled(boolean cancelled) { // this.cancelled = cancelled; // } // } // // Path: src/net/diecode/killermoney/objects/CCommand.java // public class CCommand { // // private String command; // private String permission; // private double chance; // private int limit; // private HashMap<UUID, Integer> limitCounter = new HashMap<UUID, Integer>(); // // public CCommand(String command, String permission, double chance, int limit) { // this.command = command; // this.permission = permission; // this.chance = chance; // this.limit = limit; // } // // public String getCommand() { // return command; // } // // public String getPermission() { // return permission; // } // // public double getChance() { // return chance; // } // // public int getLimit() { // return limit; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public HashMap<UUID, Integer> getLimitCounter() { // return limitCounter; // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // if (current >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // limitCounter.put(uuid, current + 1); // } else { // limitCounter.put(uuid, 1); // } // } // // public int getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return 0; // } // } // // Path: src/net/diecode/killermoney/objects/CCommandProperties.java // public class CCommandProperties { // // private RunMethod runMethod; // private ArrayList<CCommand> cCommands; // private boolean enabled; // // public CCommandProperties(RunMethod runMethod, ArrayList<CCommand> cCommands, boolean enabled) { // this.runMethod = runMethod; // this.cCommands = cCommands; // this.enabled = enabled; // } // // public RunMethod getRunMethod() { // return runMethod; // } // // public ArrayList<CCommand> getCCommands() { // return cCommands; // } // // public boolean isEnabled() { // return enabled; // } // }
import net.diecode.killermoney.enums.KMPermission; import net.diecode.killermoney.enums.RunMethod; import net.diecode.killermoney.events.KMCCommandExecutionEvent; import net.diecode.killermoney.objects.CCommand; import net.diecode.killermoney.objects.CCommandProperties; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import java.util.ArrayList; import java.util.Random;
package net.diecode.killermoney.functions; public class CCommandHandler implements Listener { @EventHandler (priority = EventPriority.LOW) public void onCustomCommand(KMCCommandExecutionEvent e) { if (e.isCancelled()) { return; } String command = e.getCCommand().getCommand(); if (command != null) { command = command.replace("{player}", e.getKiller().getName()); e.getCCommand().increaseLimitCounter(e.getKiller().getUniqueId()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); } } public static void process(CCommandProperties cCommandProperties, LivingEntity livingEntity, Player killer) {
// Path: src/net/diecode/killermoney/enums/KMPermission.java // public enum KMPermission { // // ADMIN("admin"), // MONEY_MULTIPLIER("money.multiplier"), // // LIMIT_MONEY_MULTIPLIER("moneylimit.multiplier"), // //LIMIT_ITEM_MULTIPLIER("itemlimit.multiplier"), // //LIMIT_COMMAND_MULTIPLIER("commandlimit.multiplier"), // // BYPASS_MONEY_LIMIT("bypass.moneylimit"), // BYPASS_ITEM_LIMIT("bypass.itemlimit"), // BYPASS_COMMAND_LIMIT("bypass.commandlimit"), // BYPASS_MONEY_LIMIT_CASH_TRANSFER("bypass.cashtransferlimit"); // // private String perm; // // KMPermission(String perm) { // this.perm = perm; // } // // public String get() { // return "km." + perm; // } // // } // // Path: src/net/diecode/killermoney/enums/RunMethod.java // public enum RunMethod { // // ALL, RANDOM // // } // // Path: src/net/diecode/killermoney/events/KMCCommandExecutionEvent.java // public class KMCCommandExecutionEvent extends Event implements Cancellable { // // private static final HandlerList handlers = new HandlerList(); // // private CCommand cCommand; // private Player killer; // private LivingEntity victim; // private boolean cancelled; // // public KMCCommandExecutionEvent(CCommand cCommand, Player killer, LivingEntity victim) { // this.cCommand = cCommand; // this.killer = killer; // this.victim = victim; // } // // public HandlerList getHandlers() { // return handlers; // } // // public static HandlerList getHandlerList() { // return handlers; // } // // public CCommand getCCommand() { // return cCommand; // } // // public Player getKiller() { // return killer; // } // // public LivingEntity getVictim() { // return victim; // } // // @Override // public boolean isCancelled() { // return cancelled; // } // // @Override // public void setCancelled(boolean cancelled) { // this.cancelled = cancelled; // } // } // // Path: src/net/diecode/killermoney/objects/CCommand.java // public class CCommand { // // private String command; // private String permission; // private double chance; // private int limit; // private HashMap<UUID, Integer> limitCounter = new HashMap<UUID, Integer>(); // // public CCommand(String command, String permission, double chance, int limit) { // this.command = command; // this.permission = permission; // this.chance = chance; // this.limit = limit; // } // // public String getCommand() { // return command; // } // // public String getPermission() { // return permission; // } // // public double getChance() { // return chance; // } // // public int getLimit() { // return limit; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public HashMap<UUID, Integer> getLimitCounter() { // return limitCounter; // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // if (current >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // limitCounter.put(uuid, current + 1); // } else { // limitCounter.put(uuid, 1); // } // } // // public int getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return 0; // } // } // // Path: src/net/diecode/killermoney/objects/CCommandProperties.java // public class CCommandProperties { // // private RunMethod runMethod; // private ArrayList<CCommand> cCommands; // private boolean enabled; // // public CCommandProperties(RunMethod runMethod, ArrayList<CCommand> cCommands, boolean enabled) { // this.runMethod = runMethod; // this.cCommands = cCommands; // this.enabled = enabled; // } // // public RunMethod getRunMethod() { // return runMethod; // } // // public ArrayList<CCommand> getCCommands() { // return cCommands; // } // // public boolean isEnabled() { // return enabled; // } // } // Path: src/net/diecode/killermoney/functions/CCommandHandler.java import net.diecode.killermoney.enums.KMPermission; import net.diecode.killermoney.enums.RunMethod; import net.diecode.killermoney.events.KMCCommandExecutionEvent; import net.diecode.killermoney.objects.CCommand; import net.diecode.killermoney.objects.CCommandProperties; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import java.util.ArrayList; import java.util.Random; package net.diecode.killermoney.functions; public class CCommandHandler implements Listener { @EventHandler (priority = EventPriority.LOW) public void onCustomCommand(KMCCommandExecutionEvent e) { if (e.isCancelled()) { return; } String command = e.getCCommand().getCommand(); if (command != null) { command = command.replace("{player}", e.getKiller().getName()); e.getCCommand().increaseLimitCounter(e.getKiller().getUniqueId()); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); } } public static void process(CCommandProperties cCommandProperties, LivingEntity livingEntity, Player killer) {
ArrayList<CCommand> commands = new ArrayList<CCommand>();
diecode/KillerMoney
src/net/diecode/killermoney/events/KMEarnMoneyCashTransferDepositEvent.java
// Path: src/net/diecode/killermoney/objects/CashTransferProperties.java // public class CashTransferProperties { // // private double percent; // private int maxAmount; // private double chance; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public CashTransferProperties(double percent, int maxAmount, double chance, String permission, int limit, // DivisionMethod divisionMethod, boolean enabled) { // this.percent = percent; // this.maxAmount = maxAmount; // this.chance = chance; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public double getPercent() { // return percent; // } // // public int getMaxAmount() { // return maxAmount; // } // // public double getChance() { // return chance; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean isEnabled() { // return enabled; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.doubleValue() >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // }
import net.diecode.killermoney.objects.CashTransferProperties; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.math.BigDecimal;
package net.diecode.killermoney.events; public class KMEarnMoneyCashTransferDepositEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList();
// Path: src/net/diecode/killermoney/objects/CashTransferProperties.java // public class CashTransferProperties { // // private double percent; // private int maxAmount; // private double chance; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public CashTransferProperties(double percent, int maxAmount, double chance, String permission, int limit, // DivisionMethod divisionMethod, boolean enabled) { // this.percent = percent; // this.maxAmount = maxAmount; // this.chance = chance; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public double getPercent() { // return percent; // } // // public int getMaxAmount() { // return maxAmount; // } // // public double getChance() { // return chance; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean isEnabled() { // return enabled; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.doubleValue() >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // } // Path: src/net/diecode/killermoney/events/KMEarnMoneyCashTransferDepositEvent.java import net.diecode.killermoney.objects.CashTransferProperties; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.math.BigDecimal; package net.diecode.killermoney.events; public class KMEarnMoneyCashTransferDepositEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList();
private CashTransferProperties cashTransferProperties;
diecode/KillerMoney
src/net/diecode/killermoney/events/KMEarnMoneyDepositEvent.java
// Path: src/net/diecode/killermoney/objects/MoneyProperties.java // public class MoneyProperties { // // private EntityType entityType; // private double chance; // private double minMoney; // private double maxMoney; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public MoneyProperties(EntityType entityType, double chance, double minMoney, double maxMoney, String permission, // int limit, DivisionMethod divisionMethod, boolean enabled) { // this.entityType = entityType; // this.chance = chance; // this.minMoney = minMoney; // this.maxMoney = maxMoney; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public EntityType getEntityType() { // return entityType; // } // // public double getChance() { // return chance; // } // // public double getMinMoney() { // return minMoney; // } // // public double getMaxMoney() { // return maxMoney; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public boolean isEnabled() { // return enabled; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player != null) { // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // } // // BigDecimal limit = getLimit(player); // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.compareTo(limit) >= 0) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // // public BigDecimal getLimit(Player player) { // if (player == null) { // return new BigDecimal(limit); // } // // return new BigDecimal(limit * MultiplierHandler.getPermBasedMoneyLimitMultiplier(player)) // .setScale(DefaultConfig.getDecimalPlaces(), BigDecimal.ROUND_HALF_EVEN); // } // }
import net.diecode.killermoney.objects.MoneyProperties; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.math.BigDecimal;
package net.diecode.killermoney.events; public class KMEarnMoneyDepositEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList();
// Path: src/net/diecode/killermoney/objects/MoneyProperties.java // public class MoneyProperties { // // private EntityType entityType; // private double chance; // private double minMoney; // private double maxMoney; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public MoneyProperties(EntityType entityType, double chance, double minMoney, double maxMoney, String permission, // int limit, DivisionMethod divisionMethod, boolean enabled) { // this.entityType = entityType; // this.chance = chance; // this.minMoney = minMoney; // this.maxMoney = maxMoney; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public EntityType getEntityType() { // return entityType; // } // // public double getChance() { // return chance; // } // // public double getMinMoney() { // return minMoney; // } // // public double getMaxMoney() { // return maxMoney; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public boolean isEnabled() { // return enabled; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player != null) { // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // } // // BigDecimal limit = getLimit(player); // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.compareTo(limit) >= 0) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // // public BigDecimal getLimit(Player player) { // if (player == null) { // return new BigDecimal(limit); // } // // return new BigDecimal(limit * MultiplierHandler.getPermBasedMoneyLimitMultiplier(player)) // .setScale(DefaultConfig.getDecimalPlaces(), BigDecimal.ROUND_HALF_EVEN); // } // } // Path: src/net/diecode/killermoney/events/KMEarnMoneyDepositEvent.java import net.diecode.killermoney.objects.MoneyProperties; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.math.BigDecimal; package net.diecode.killermoney.events; public class KMEarnMoneyDepositEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList();
private MoneyProperties moneyProperties;
diecode/KillerMoney
src/net/diecode/killermoney/commands/subcommands/kmadmin/HelpCommand.java
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/enums/SenderType.java // public enum SenderType { // // PLAYER, CONSOLE, ANYONE // // } // // Path: src/net/diecode/killermoney/objects/KMSubCommand.java // public abstract class KMSubCommand { // // protected ArrayList<KMCommandType> usable; // protected String command; // protected KMPermission permission; // protected SenderType senderType; // protected int minArgs; // protected String usage; // protected ArrayList<String> aliases; // protected ArrayList<String> acceptableValues; // // public KMSubCommand(ArrayList<KMCommandType> usable, String command) { // this.usable = usable; // this.command = command; // } // // public ArrayList<KMCommandType> getUsable() { // return usable; // } // // public String getCommand() { // return command; // } // // public KMPermission getPermission() { // return permission; // } // // public SenderType getSenderType() { // return senderType; // } // // public int getMinArgs() { // return minArgs; // } // // public String getUsage() { // return usage; // } // // public ArrayList<String> getAliases() { // return aliases; // } // // public ArrayList<String> getAcceptableValues() { // return acceptableValues; // } // // public abstract void run(CommandSender cs, String[] args); // }
import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.enums.SenderType; import net.diecode.killermoney.objects.KMSubCommand; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import java.util.ArrayList;
package net.diecode.killermoney.commands.subcommands.kmadmin; public class HelpCommand extends KMSubCommand { public HelpCommand(String command) { super(
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/enums/SenderType.java // public enum SenderType { // // PLAYER, CONSOLE, ANYONE // // } // // Path: src/net/diecode/killermoney/objects/KMSubCommand.java // public abstract class KMSubCommand { // // protected ArrayList<KMCommandType> usable; // protected String command; // protected KMPermission permission; // protected SenderType senderType; // protected int minArgs; // protected String usage; // protected ArrayList<String> aliases; // protected ArrayList<String> acceptableValues; // // public KMSubCommand(ArrayList<KMCommandType> usable, String command) { // this.usable = usable; // this.command = command; // } // // public ArrayList<KMCommandType> getUsable() { // return usable; // } // // public String getCommand() { // return command; // } // // public KMPermission getPermission() { // return permission; // } // // public SenderType getSenderType() { // return senderType; // } // // public int getMinArgs() { // return minArgs; // } // // public String getUsage() { // return usage; // } // // public ArrayList<String> getAliases() { // return aliases; // } // // public ArrayList<String> getAcceptableValues() { // return acceptableValues; // } // // public abstract void run(CommandSender cs, String[] args); // } // Path: src/net/diecode/killermoney/commands/subcommands/kmadmin/HelpCommand.java import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.enums.SenderType; import net.diecode.killermoney.objects.KMSubCommand; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import java.util.ArrayList; package net.diecode.killermoney.commands.subcommands.kmadmin; public class HelpCommand extends KMSubCommand { public HelpCommand(String command) { super(
new ArrayList<KMCommandType>()
diecode/KillerMoney
src/net/diecode/killermoney/commands/subcommands/kmadmin/HelpCommand.java
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/enums/SenderType.java // public enum SenderType { // // PLAYER, CONSOLE, ANYONE // // } // // Path: src/net/diecode/killermoney/objects/KMSubCommand.java // public abstract class KMSubCommand { // // protected ArrayList<KMCommandType> usable; // protected String command; // protected KMPermission permission; // protected SenderType senderType; // protected int minArgs; // protected String usage; // protected ArrayList<String> aliases; // protected ArrayList<String> acceptableValues; // // public KMSubCommand(ArrayList<KMCommandType> usable, String command) { // this.usable = usable; // this.command = command; // } // // public ArrayList<KMCommandType> getUsable() { // return usable; // } // // public String getCommand() { // return command; // } // // public KMPermission getPermission() { // return permission; // } // // public SenderType getSenderType() { // return senderType; // } // // public int getMinArgs() { // return minArgs; // } // // public String getUsage() { // return usage; // } // // public ArrayList<String> getAliases() { // return aliases; // } // // public ArrayList<String> getAcceptableValues() { // return acceptableValues; // } // // public abstract void run(CommandSender cs, String[] args); // }
import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.enums.SenderType; import net.diecode.killermoney.objects.KMSubCommand; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import java.util.ArrayList;
package net.diecode.killermoney.commands.subcommands.kmadmin; public class HelpCommand extends KMSubCommand { public HelpCommand(String command) { super( new ArrayList<KMCommandType>() { { add(KMCommandType.KM_ADMIN); } }, command ); minArgs = 0;
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/enums/SenderType.java // public enum SenderType { // // PLAYER, CONSOLE, ANYONE // // } // // Path: src/net/diecode/killermoney/objects/KMSubCommand.java // public abstract class KMSubCommand { // // protected ArrayList<KMCommandType> usable; // protected String command; // protected KMPermission permission; // protected SenderType senderType; // protected int minArgs; // protected String usage; // protected ArrayList<String> aliases; // protected ArrayList<String> acceptableValues; // // public KMSubCommand(ArrayList<KMCommandType> usable, String command) { // this.usable = usable; // this.command = command; // } // // public ArrayList<KMCommandType> getUsable() { // return usable; // } // // public String getCommand() { // return command; // } // // public KMPermission getPermission() { // return permission; // } // // public SenderType getSenderType() { // return senderType; // } // // public int getMinArgs() { // return minArgs; // } // // public String getUsage() { // return usage; // } // // public ArrayList<String> getAliases() { // return aliases; // } // // public ArrayList<String> getAcceptableValues() { // return acceptableValues; // } // // public abstract void run(CommandSender cs, String[] args); // } // Path: src/net/diecode/killermoney/commands/subcommands/kmadmin/HelpCommand.java import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.enums.SenderType; import net.diecode.killermoney.objects.KMSubCommand; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import java.util.ArrayList; package net.diecode.killermoney.commands.subcommands.kmadmin; public class HelpCommand extends KMSubCommand { public HelpCommand(String command) { super( new ArrayList<KMCommandType>() { { add(KMCommandType.KM_ADMIN); } }, command ); minArgs = 0;
senderType = SenderType.ANYONE;
diecode/KillerMoney
src/net/diecode/killermoney/objects/CItem.java
// Path: src/net/diecode/killermoney/Utils.java // public class Utils { // // public static boolean chanceGenerator(double chance) { // return (Math.random() * 100) < chance; // } // // public static double randomNumber(double min, double max) { // if (min == max) { // return min; // } // // double randomNumber = new Random().nextDouble(); // // if (max > min) { // return min + (max - min) * randomNumber; // } // // if (min > max) { // return max + (min - max) * randomNumber; // } // // return 0; // } // // public static int randomNumber(int min, int max) { // if (min == max) { // return min; // } // // return new Random().nextInt(max - min) + min; // } // // public static boolean inEntityEnum(String entity) { // for (EntityType et : EntityType.values()) { // if (et.name().equalsIgnoreCase(entity)) { // return true; // } // } // // return false; // } // // public static boolean inDivisionEnum(String division) { // for (DivisionMethod div : DivisionMethod.values()) { // if (div.name().equalsIgnoreCase(division)) { // return true; // } // } // // return false; // } // // public static boolean inRunMethodEnum(String runMethod) { // for (RunMethod rm : RunMethod.values()) { // if (rm.name().equalsIgnoreCase(runMethod)) { // return true; // } // } // // return false; // } // // public static double cleanChanceString(String str) { // double chance = Double.valueOf(str.replaceAll("%", "")); // // if (chance > 100) { // chance = 100; // } // // if (chance < 1) { // chance = 1; // } // // return chance; // } // // /* // public static int getMoneyMultiplier(Player p) { // int multiplier = 1; // // for (PermissionAttachmentInfo pai : p.getEffectivePermissions()) { // String perm = pai.getPermission().toLowerCase(); // // if (perm.contains(Permissions.MONEY_MULTIPLIER.getPerm())) { // perm = perm.replace(Permissions.MONEY_MULTIPLIER.getPerm() + ".", ""); // int tmpMultiplier = Integer.valueOf(perm); // // if (tmpMultiplier > multiplier) { // multiplier = tmpMultiplier; // } // } // } // // return multiplier; // } // */ // // public static String getRemainingTimeHumanFormat(int remainingTime) { // final int MINUTES_IN_DAY = 1440; // final int MINUTES_IN_HOUR = 60; // // int minutes = remainingTime; // // int days = minutes / MINUTES_IN_DAY; // minutes = minutes - (days * MINUTES_IN_DAY); // // int hours = minutes / MINUTES_IN_HOUR; // minutes = minutes - (hours * MINUTES_IN_HOUR); // // StringBuilder sb = new StringBuilder(); // // if (days > 0) { // if (days == 1) { // sb.append(days + " day"); // } else { // sb.append(days + " days"); // } // if (hours > 0 || minutes > 0) { // sb.append(", "); // } // } // // if (hours > 0) { // if (hours == 1) { // sb.append(hours + " hour"); // } else { // sb.append(hours + " hours"); // } // if (minutes > 0) { // sb.append(", "); // } // } // // if (minutes > 0) { // if (minutes == 1) { // sb.append(minutes + " minute"); // } else { // sb.append(minutes + " minutes"); // } // } // // if (sb.length() == 0) { // sb.append("< 1 minute"); // } // // return sb.toString(); // } // // public static boolean isValidInput(ArrayList<String> list, String value) { // for (String s : list) { // if (s.equalsIgnoreCase(value)) { // return true; // } // } // // return false; // } // // public static boolean getBoolean(String value) { // if (value.equalsIgnoreCase("on") || value.equalsIgnoreCase("true") // || value.equalsIgnoreCase("enable") || value.equalsIgnoreCase("1")) { // return true; // } // // return false; // } // // }
import net.diecode.killermoney.Utils; import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.UUID;
this.chance = chance; this.permission = permission; this.limit = limit; } public ItemStack getItemStack() { return itemStack; } public int getMinAmount() { return minAmount; } public int getMaxAmount() { return maxAmount; } public double getChance() { return chance; } public String getPermission() { return permission; } public int getLimit() { return limit; } public boolean chanceGen() {
// Path: src/net/diecode/killermoney/Utils.java // public class Utils { // // public static boolean chanceGenerator(double chance) { // return (Math.random() * 100) < chance; // } // // public static double randomNumber(double min, double max) { // if (min == max) { // return min; // } // // double randomNumber = new Random().nextDouble(); // // if (max > min) { // return min + (max - min) * randomNumber; // } // // if (min > max) { // return max + (min - max) * randomNumber; // } // // return 0; // } // // public static int randomNumber(int min, int max) { // if (min == max) { // return min; // } // // return new Random().nextInt(max - min) + min; // } // // public static boolean inEntityEnum(String entity) { // for (EntityType et : EntityType.values()) { // if (et.name().equalsIgnoreCase(entity)) { // return true; // } // } // // return false; // } // // public static boolean inDivisionEnum(String division) { // for (DivisionMethod div : DivisionMethod.values()) { // if (div.name().equalsIgnoreCase(division)) { // return true; // } // } // // return false; // } // // public static boolean inRunMethodEnum(String runMethod) { // for (RunMethod rm : RunMethod.values()) { // if (rm.name().equalsIgnoreCase(runMethod)) { // return true; // } // } // // return false; // } // // public static double cleanChanceString(String str) { // double chance = Double.valueOf(str.replaceAll("%", "")); // // if (chance > 100) { // chance = 100; // } // // if (chance < 1) { // chance = 1; // } // // return chance; // } // // /* // public static int getMoneyMultiplier(Player p) { // int multiplier = 1; // // for (PermissionAttachmentInfo pai : p.getEffectivePermissions()) { // String perm = pai.getPermission().toLowerCase(); // // if (perm.contains(Permissions.MONEY_MULTIPLIER.getPerm())) { // perm = perm.replace(Permissions.MONEY_MULTIPLIER.getPerm() + ".", ""); // int tmpMultiplier = Integer.valueOf(perm); // // if (tmpMultiplier > multiplier) { // multiplier = tmpMultiplier; // } // } // } // // return multiplier; // } // */ // // public static String getRemainingTimeHumanFormat(int remainingTime) { // final int MINUTES_IN_DAY = 1440; // final int MINUTES_IN_HOUR = 60; // // int minutes = remainingTime; // // int days = minutes / MINUTES_IN_DAY; // minutes = minutes - (days * MINUTES_IN_DAY); // // int hours = minutes / MINUTES_IN_HOUR; // minutes = minutes - (hours * MINUTES_IN_HOUR); // // StringBuilder sb = new StringBuilder(); // // if (days > 0) { // if (days == 1) { // sb.append(days + " day"); // } else { // sb.append(days + " days"); // } // if (hours > 0 || minutes > 0) { // sb.append(", "); // } // } // // if (hours > 0) { // if (hours == 1) { // sb.append(hours + " hour"); // } else { // sb.append(hours + " hours"); // } // if (minutes > 0) { // sb.append(", "); // } // } // // if (minutes > 0) { // if (minutes == 1) { // sb.append(minutes + " minute"); // } else { // sb.append(minutes + " minutes"); // } // } // // if (sb.length() == 0) { // sb.append("< 1 minute"); // } // // return sb.toString(); // } // // public static boolean isValidInput(ArrayList<String> list, String value) { // for (String s : list) { // if (s.equalsIgnoreCase(value)) { // return true; // } // } // // return false; // } // // public static boolean getBoolean(String value) { // if (value.equalsIgnoreCase("on") || value.equalsIgnoreCase("true") // || value.equalsIgnoreCase("enable") || value.equalsIgnoreCase("1")) { // return true; // } // // return false; // } // // } // Path: src/net/diecode/killermoney/objects/CItem.java import net.diecode.killermoney.Utils; import org.bukkit.inventory.ItemStack; import java.util.HashMap; import java.util.UUID; this.chance = chance; this.permission = permission; this.limit = limit; } public ItemStack getItemStack() { return itemStack; } public int getMinAmount() { return minAmount; } public int getMaxAmount() { return maxAmount; } public double getChance() { return chance; } public String getPermission() { return permission; } public int getLimit() { return limit; } public boolean chanceGen() {
return Utils.chanceGenerator(this.chance);
diecode/KillerMoney
src/net/diecode/killermoney/configs/DefaultConfig.java
// Path: src/net/diecode/killermoney/Logger.java // public class Logger { // // private static java.util.logging.Logger logger = java.util.logging.Logger.getLogger("[Minecraft]"); // private static String consolePrefix = "[KillerMoney] "; // // public static void info(String message) { // logger.info(consolePrefix + message); // } // // public static void debug(String message) { // logger.info(consolePrefix + "[DEBUG] " + message); // } // // public static void warning(String message) { // logger.warning(consolePrefix + message); // } // } // // Path: src/net/diecode/killermoney/enums/MessageMethod.java // public enum MessageMethod { // // DISABLED, CHAT, ACTION_BAR // // } // // Path: src/net/diecode/killermoney/functions/MessageHandler.java // public class MessageHandler implements Listener { // // private static IActionBar actionBar; // private static HashMap<UUID, BukkitTask> timers = new HashMap<UUID, BukkitTask>(); // // @EventHandler // public void onSendMessage(KMSendMessageEvent e) { // e.getPlayer().sendMessage(LanguageManager.cGet(LanguageString.GENERAL_PREFIX) + e.getMessage()); // } // // @EventHandler // public void onActionBarMessage(final KMSendActionBarMessageEvent e) { // final UUID puuid = e.getPlayer().getUniqueId(); // // if (timers.containsKey(puuid)) { // BukkitTask task = timers.get(puuid); // // task.cancel(); // } // // BukkitTask task = Bukkit.getScheduler().runTaskTimer(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // actionBar.sendActionBarMessage(e.getPlayer(), e.getMessage()); // } // }, 0L, 20L); // // timers.put(puuid, task); // // Bukkit.getScheduler().runTaskLater(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // if (timers.containsKey(puuid)) { // timers.get(puuid).cancel(); // } // } // }, e.getDuration() * 20L); // } // // public static void process(Player player, String message) { // KMPlayer kmp = KMPlayerManager.getKMPlayer(player); // PluginManager pm = Bukkit.getPluginManager(); // // if (kmp == null || !kmp.isEnableMessages()) { // return; // } // // switch (DefaultConfig.getMessageMethod()) { // case DISABLED: return; // // case ACTION_BAR: pm.callEvent(new KMSendActionBarMessageEvent(player, message, 3)); // break; // // case CHAT: pm.callEvent(new KMSendMessageEvent(player, message)); // break; // } // } // // public static void initActionBar() { // String version; // // try { // version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; // // Class actionBarClass = Class.forName("net.diecode.killermoney.compatibility.actionbar.ActionBar_" + version); // // actionBar = (IActionBar)actionBarClass.newInstance(); // } catch (Exception e) { // Logger.warning("Action bar is not compatibility with this server version. Using default \"CHAT\" value."); // // DefaultConfig.setMessageMethod(MessageMethod.CHAT); // } // } // // }
import net.diecode.killermoney.Logger; import net.diecode.killermoney.enums.MessageMethod; import net.diecode.killermoney.functions.MessageHandler; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import java.util.ArrayList; import java.util.HashMap; import java.util.Set;
package net.diecode.killermoney.configs; public class DefaultConfig extends SuperConfig { private static DefaultConfig instance; private static int configVersion; private static boolean checkUpdate; private static int decimalPlaces;
// Path: src/net/diecode/killermoney/Logger.java // public class Logger { // // private static java.util.logging.Logger logger = java.util.logging.Logger.getLogger("[Minecraft]"); // private static String consolePrefix = "[KillerMoney] "; // // public static void info(String message) { // logger.info(consolePrefix + message); // } // // public static void debug(String message) { // logger.info(consolePrefix + "[DEBUG] " + message); // } // // public static void warning(String message) { // logger.warning(consolePrefix + message); // } // } // // Path: src/net/diecode/killermoney/enums/MessageMethod.java // public enum MessageMethod { // // DISABLED, CHAT, ACTION_BAR // // } // // Path: src/net/diecode/killermoney/functions/MessageHandler.java // public class MessageHandler implements Listener { // // private static IActionBar actionBar; // private static HashMap<UUID, BukkitTask> timers = new HashMap<UUID, BukkitTask>(); // // @EventHandler // public void onSendMessage(KMSendMessageEvent e) { // e.getPlayer().sendMessage(LanguageManager.cGet(LanguageString.GENERAL_PREFIX) + e.getMessage()); // } // // @EventHandler // public void onActionBarMessage(final KMSendActionBarMessageEvent e) { // final UUID puuid = e.getPlayer().getUniqueId(); // // if (timers.containsKey(puuid)) { // BukkitTask task = timers.get(puuid); // // task.cancel(); // } // // BukkitTask task = Bukkit.getScheduler().runTaskTimer(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // actionBar.sendActionBarMessage(e.getPlayer(), e.getMessage()); // } // }, 0L, 20L); // // timers.put(puuid, task); // // Bukkit.getScheduler().runTaskLater(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // if (timers.containsKey(puuid)) { // timers.get(puuid).cancel(); // } // } // }, e.getDuration() * 20L); // } // // public static void process(Player player, String message) { // KMPlayer kmp = KMPlayerManager.getKMPlayer(player); // PluginManager pm = Bukkit.getPluginManager(); // // if (kmp == null || !kmp.isEnableMessages()) { // return; // } // // switch (DefaultConfig.getMessageMethod()) { // case DISABLED: return; // // case ACTION_BAR: pm.callEvent(new KMSendActionBarMessageEvent(player, message, 3)); // break; // // case CHAT: pm.callEvent(new KMSendMessageEvent(player, message)); // break; // } // } // // public static void initActionBar() { // String version; // // try { // version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; // // Class actionBarClass = Class.forName("net.diecode.killermoney.compatibility.actionbar.ActionBar_" + version); // // actionBar = (IActionBar)actionBarClass.newInstance(); // } catch (Exception e) { // Logger.warning("Action bar is not compatibility with this server version. Using default \"CHAT\" value."); // // DefaultConfig.setMessageMethod(MessageMethod.CHAT); // } // } // // } // Path: src/net/diecode/killermoney/configs/DefaultConfig.java import net.diecode.killermoney.Logger; import net.diecode.killermoney.enums.MessageMethod; import net.diecode.killermoney.functions.MessageHandler; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import java.util.ArrayList; import java.util.HashMap; import java.util.Set; package net.diecode.killermoney.configs; public class DefaultConfig extends SuperConfig { private static DefaultConfig instance; private static int configVersion; private static boolean checkUpdate; private static int decimalPlaces;
private static MessageMethod messageMethod;
diecode/KillerMoney
src/net/diecode/killermoney/configs/DefaultConfig.java
// Path: src/net/diecode/killermoney/Logger.java // public class Logger { // // private static java.util.logging.Logger logger = java.util.logging.Logger.getLogger("[Minecraft]"); // private static String consolePrefix = "[KillerMoney] "; // // public static void info(String message) { // logger.info(consolePrefix + message); // } // // public static void debug(String message) { // logger.info(consolePrefix + "[DEBUG] " + message); // } // // public static void warning(String message) { // logger.warning(consolePrefix + message); // } // } // // Path: src/net/diecode/killermoney/enums/MessageMethod.java // public enum MessageMethod { // // DISABLED, CHAT, ACTION_BAR // // } // // Path: src/net/diecode/killermoney/functions/MessageHandler.java // public class MessageHandler implements Listener { // // private static IActionBar actionBar; // private static HashMap<UUID, BukkitTask> timers = new HashMap<UUID, BukkitTask>(); // // @EventHandler // public void onSendMessage(KMSendMessageEvent e) { // e.getPlayer().sendMessage(LanguageManager.cGet(LanguageString.GENERAL_PREFIX) + e.getMessage()); // } // // @EventHandler // public void onActionBarMessage(final KMSendActionBarMessageEvent e) { // final UUID puuid = e.getPlayer().getUniqueId(); // // if (timers.containsKey(puuid)) { // BukkitTask task = timers.get(puuid); // // task.cancel(); // } // // BukkitTask task = Bukkit.getScheduler().runTaskTimer(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // actionBar.sendActionBarMessage(e.getPlayer(), e.getMessage()); // } // }, 0L, 20L); // // timers.put(puuid, task); // // Bukkit.getScheduler().runTaskLater(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // if (timers.containsKey(puuid)) { // timers.get(puuid).cancel(); // } // } // }, e.getDuration() * 20L); // } // // public static void process(Player player, String message) { // KMPlayer kmp = KMPlayerManager.getKMPlayer(player); // PluginManager pm = Bukkit.getPluginManager(); // // if (kmp == null || !kmp.isEnableMessages()) { // return; // } // // switch (DefaultConfig.getMessageMethod()) { // case DISABLED: return; // // case ACTION_BAR: pm.callEvent(new KMSendActionBarMessageEvent(player, message, 3)); // break; // // case CHAT: pm.callEvent(new KMSendMessageEvent(player, message)); // break; // } // } // // public static void initActionBar() { // String version; // // try { // version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; // // Class actionBarClass = Class.forName("net.diecode.killermoney.compatibility.actionbar.ActionBar_" + version); // // actionBar = (IActionBar)actionBarClass.newInstance(); // } catch (Exception e) { // Logger.warning("Action bar is not compatibility with this server version. Using default \"CHAT\" value."); // // DefaultConfig.setMessageMethod(MessageMethod.CHAT); // } // } // // }
import net.diecode.killermoney.Logger; import net.diecode.killermoney.enums.MessageMethod; import net.diecode.killermoney.functions.MessageHandler; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import java.util.ArrayList; import java.util.HashMap; import java.util.Set;
instance = this; init(); } private void init() { // Get config version configVersion = DefaultConfig.getInstance().getConfig().getInt("Config-version"); } @Override public void load() { reload(); // Get config version configVersion = DefaultConfig.getInstance().getConfig().getInt("Config-version"); // Check update checkUpdate = getConfig().getBoolean("Check-update"); // Money decimal places decimalPlaces = getConfig().getInt("Global-settings.Money.Decimal-places"); // Message method value try { messageMethod = MessageMethod.valueOf(getConfig().getString("Global-settings.General.Message-method").toUpperCase()); } catch (Exception e) { messageMethod = MessageMethod.CHAT;
// Path: src/net/diecode/killermoney/Logger.java // public class Logger { // // private static java.util.logging.Logger logger = java.util.logging.Logger.getLogger("[Minecraft]"); // private static String consolePrefix = "[KillerMoney] "; // // public static void info(String message) { // logger.info(consolePrefix + message); // } // // public static void debug(String message) { // logger.info(consolePrefix + "[DEBUG] " + message); // } // // public static void warning(String message) { // logger.warning(consolePrefix + message); // } // } // // Path: src/net/diecode/killermoney/enums/MessageMethod.java // public enum MessageMethod { // // DISABLED, CHAT, ACTION_BAR // // } // // Path: src/net/diecode/killermoney/functions/MessageHandler.java // public class MessageHandler implements Listener { // // private static IActionBar actionBar; // private static HashMap<UUID, BukkitTask> timers = new HashMap<UUID, BukkitTask>(); // // @EventHandler // public void onSendMessage(KMSendMessageEvent e) { // e.getPlayer().sendMessage(LanguageManager.cGet(LanguageString.GENERAL_PREFIX) + e.getMessage()); // } // // @EventHandler // public void onActionBarMessage(final KMSendActionBarMessageEvent e) { // final UUID puuid = e.getPlayer().getUniqueId(); // // if (timers.containsKey(puuid)) { // BukkitTask task = timers.get(puuid); // // task.cancel(); // } // // BukkitTask task = Bukkit.getScheduler().runTaskTimer(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // actionBar.sendActionBarMessage(e.getPlayer(), e.getMessage()); // } // }, 0L, 20L); // // timers.put(puuid, task); // // Bukkit.getScheduler().runTaskLater(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // if (timers.containsKey(puuid)) { // timers.get(puuid).cancel(); // } // } // }, e.getDuration() * 20L); // } // // public static void process(Player player, String message) { // KMPlayer kmp = KMPlayerManager.getKMPlayer(player); // PluginManager pm = Bukkit.getPluginManager(); // // if (kmp == null || !kmp.isEnableMessages()) { // return; // } // // switch (DefaultConfig.getMessageMethod()) { // case DISABLED: return; // // case ACTION_BAR: pm.callEvent(new KMSendActionBarMessageEvent(player, message, 3)); // break; // // case CHAT: pm.callEvent(new KMSendMessageEvent(player, message)); // break; // } // } // // public static void initActionBar() { // String version; // // try { // version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; // // Class actionBarClass = Class.forName("net.diecode.killermoney.compatibility.actionbar.ActionBar_" + version); // // actionBar = (IActionBar)actionBarClass.newInstance(); // } catch (Exception e) { // Logger.warning("Action bar is not compatibility with this server version. Using default \"CHAT\" value."); // // DefaultConfig.setMessageMethod(MessageMethod.CHAT); // } // } // // } // Path: src/net/diecode/killermoney/configs/DefaultConfig.java import net.diecode.killermoney.Logger; import net.diecode.killermoney.enums.MessageMethod; import net.diecode.killermoney.functions.MessageHandler; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import java.util.ArrayList; import java.util.HashMap; import java.util.Set; instance = this; init(); } private void init() { // Get config version configVersion = DefaultConfig.getInstance().getConfig().getInt("Config-version"); } @Override public void load() { reload(); // Get config version configVersion = DefaultConfig.getInstance().getConfig().getInt("Config-version"); // Check update checkUpdate = getConfig().getBoolean("Check-update"); // Money decimal places decimalPlaces = getConfig().getInt("Global-settings.Money.Decimal-places"); // Message method value try { messageMethod = MessageMethod.valueOf(getConfig().getString("Global-settings.General.Message-method").toUpperCase()); } catch (Exception e) { messageMethod = MessageMethod.CHAT;
Logger.warning("Invalid message method value. Using default \"CHAT\" value.");
diecode/KillerMoney
src/net/diecode/killermoney/configs/DefaultConfig.java
// Path: src/net/diecode/killermoney/Logger.java // public class Logger { // // private static java.util.logging.Logger logger = java.util.logging.Logger.getLogger("[Minecraft]"); // private static String consolePrefix = "[KillerMoney] "; // // public static void info(String message) { // logger.info(consolePrefix + message); // } // // public static void debug(String message) { // logger.info(consolePrefix + "[DEBUG] " + message); // } // // public static void warning(String message) { // logger.warning(consolePrefix + message); // } // } // // Path: src/net/diecode/killermoney/enums/MessageMethod.java // public enum MessageMethod { // // DISABLED, CHAT, ACTION_BAR // // } // // Path: src/net/diecode/killermoney/functions/MessageHandler.java // public class MessageHandler implements Listener { // // private static IActionBar actionBar; // private static HashMap<UUID, BukkitTask> timers = new HashMap<UUID, BukkitTask>(); // // @EventHandler // public void onSendMessage(KMSendMessageEvent e) { // e.getPlayer().sendMessage(LanguageManager.cGet(LanguageString.GENERAL_PREFIX) + e.getMessage()); // } // // @EventHandler // public void onActionBarMessage(final KMSendActionBarMessageEvent e) { // final UUID puuid = e.getPlayer().getUniqueId(); // // if (timers.containsKey(puuid)) { // BukkitTask task = timers.get(puuid); // // task.cancel(); // } // // BukkitTask task = Bukkit.getScheduler().runTaskTimer(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // actionBar.sendActionBarMessage(e.getPlayer(), e.getMessage()); // } // }, 0L, 20L); // // timers.put(puuid, task); // // Bukkit.getScheduler().runTaskLater(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // if (timers.containsKey(puuid)) { // timers.get(puuid).cancel(); // } // } // }, e.getDuration() * 20L); // } // // public static void process(Player player, String message) { // KMPlayer kmp = KMPlayerManager.getKMPlayer(player); // PluginManager pm = Bukkit.getPluginManager(); // // if (kmp == null || !kmp.isEnableMessages()) { // return; // } // // switch (DefaultConfig.getMessageMethod()) { // case DISABLED: return; // // case ACTION_BAR: pm.callEvent(new KMSendActionBarMessageEvent(player, message, 3)); // break; // // case CHAT: pm.callEvent(new KMSendMessageEvent(player, message)); // break; // } // } // // public static void initActionBar() { // String version; // // try { // version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; // // Class actionBarClass = Class.forName("net.diecode.killermoney.compatibility.actionbar.ActionBar_" + version); // // actionBar = (IActionBar)actionBarClass.newInstance(); // } catch (Exception e) { // Logger.warning("Action bar is not compatibility with this server version. Using default \"CHAT\" value."); // // DefaultConfig.setMessageMethod(MessageMethod.CHAT); // } // } // // }
import net.diecode.killermoney.Logger; import net.diecode.killermoney.enums.MessageMethod; import net.diecode.killermoney.functions.MessageHandler; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import java.util.ArrayList; import java.util.HashMap; import java.util.Set;
} private void init() { // Get config version configVersion = DefaultConfig.getInstance().getConfig().getInt("Config-version"); } @Override public void load() { reload(); // Get config version configVersion = DefaultConfig.getInstance().getConfig().getInt("Config-version"); // Check update checkUpdate = getConfig().getBoolean("Check-update"); // Money decimal places decimalPlaces = getConfig().getInt("Global-settings.Money.Decimal-places"); // Message method value try { messageMethod = MessageMethod.valueOf(getConfig().getString("Global-settings.General.Message-method").toUpperCase()); } catch (Exception e) { messageMethod = MessageMethod.CHAT; Logger.warning("Invalid message method value. Using default \"CHAT\" value."); } if (messageMethod == MessageMethod.ACTION_BAR) {
// Path: src/net/diecode/killermoney/Logger.java // public class Logger { // // private static java.util.logging.Logger logger = java.util.logging.Logger.getLogger("[Minecraft]"); // private static String consolePrefix = "[KillerMoney] "; // // public static void info(String message) { // logger.info(consolePrefix + message); // } // // public static void debug(String message) { // logger.info(consolePrefix + "[DEBUG] " + message); // } // // public static void warning(String message) { // logger.warning(consolePrefix + message); // } // } // // Path: src/net/diecode/killermoney/enums/MessageMethod.java // public enum MessageMethod { // // DISABLED, CHAT, ACTION_BAR // // } // // Path: src/net/diecode/killermoney/functions/MessageHandler.java // public class MessageHandler implements Listener { // // private static IActionBar actionBar; // private static HashMap<UUID, BukkitTask> timers = new HashMap<UUID, BukkitTask>(); // // @EventHandler // public void onSendMessage(KMSendMessageEvent e) { // e.getPlayer().sendMessage(LanguageManager.cGet(LanguageString.GENERAL_PREFIX) + e.getMessage()); // } // // @EventHandler // public void onActionBarMessage(final KMSendActionBarMessageEvent e) { // final UUID puuid = e.getPlayer().getUniqueId(); // // if (timers.containsKey(puuid)) { // BukkitTask task = timers.get(puuid); // // task.cancel(); // } // // BukkitTask task = Bukkit.getScheduler().runTaskTimer(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // actionBar.sendActionBarMessage(e.getPlayer(), e.getMessage()); // } // }, 0L, 20L); // // timers.put(puuid, task); // // Bukkit.getScheduler().runTaskLater(BukkitMain.getInstance(), new Runnable() { // @Override // public void run() { // if (timers.containsKey(puuid)) { // timers.get(puuid).cancel(); // } // } // }, e.getDuration() * 20L); // } // // public static void process(Player player, String message) { // KMPlayer kmp = KMPlayerManager.getKMPlayer(player); // PluginManager pm = Bukkit.getPluginManager(); // // if (kmp == null || !kmp.isEnableMessages()) { // return; // } // // switch (DefaultConfig.getMessageMethod()) { // case DISABLED: return; // // case ACTION_BAR: pm.callEvent(new KMSendActionBarMessageEvent(player, message, 3)); // break; // // case CHAT: pm.callEvent(new KMSendMessageEvent(player, message)); // break; // } // } // // public static void initActionBar() { // String version; // // try { // version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3]; // // Class actionBarClass = Class.forName("net.diecode.killermoney.compatibility.actionbar.ActionBar_" + version); // // actionBar = (IActionBar)actionBarClass.newInstance(); // } catch (Exception e) { // Logger.warning("Action bar is not compatibility with this server version. Using default \"CHAT\" value."); // // DefaultConfig.setMessageMethod(MessageMethod.CHAT); // } // } // // } // Path: src/net/diecode/killermoney/configs/DefaultConfig.java import net.diecode.killermoney.Logger; import net.diecode.killermoney.enums.MessageMethod; import net.diecode.killermoney.functions.MessageHandler; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Material; import java.util.ArrayList; import java.util.HashMap; import java.util.Set; } private void init() { // Get config version configVersion = DefaultConfig.getInstance().getConfig().getInt("Config-version"); } @Override public void load() { reload(); // Get config version configVersion = DefaultConfig.getInstance().getConfig().getInt("Config-version"); // Check update checkUpdate = getConfig().getBoolean("Check-update"); // Money decimal places decimalPlaces = getConfig().getInt("Global-settings.Money.Decimal-places"); // Message method value try { messageMethod = MessageMethod.valueOf(getConfig().getString("Global-settings.General.Message-method").toUpperCase()); } catch (Exception e) { messageMethod = MessageMethod.CHAT; Logger.warning("Invalid message method value. Using default \"CHAT\" value."); } if (messageMethod == MessageMethod.ACTION_BAR) {
MessageHandler.initActionBar();
diecode/KillerMoney
src/net/diecode/killermoney/api/CommandAPI.java
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/managers/CommandManager.java // public class CommandManager { // // private static ArrayList<KMSubCommand> subCommands = new ArrayList<>(); // // public static void onCommand(final CommandSender cs, Command cmd, String s, String[] tmpArgs, KMCommandType type) { // KMSubCommand cm = null; // // if (tmpArgs.length > 0) { // cm = getSubCommand(type, tmpArgs[0]); // } // // if (cm == null) { // cm = getSubCommand(type, "help"); // } // // if (cm != null) { // if (cm.getSenderType() == SenderType.PLAYER) { // if (!(cs instanceof Player)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_PLAYER); // // return; // } // } // // if (cm.getSenderType() == SenderType.CONSOLE) { // if (!(cs instanceof ConsoleCommandSender)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_CONSOLE); // // return; // } // } // // if (cm.getPermission() != null && !cs.hasPermission(cm.getPermission().get()) // && !cs.hasPermission(KMPermission.ADMIN.get())) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_YOU_HAVE_NOT_ENOUGH_PERMISSION, // cm.getPermission().get()); // // return; // } // // if (tmpArgs.length <= cm.getMinArgs()) { // // too few args // if (cm.getUsage() != null) { // cs.sendMessage(cm.getUsage()); // } // // return; // } // // String[] args = new String[tmpArgs.length - 1]; // // for (int i = 0; i < args.length; i++) { // args[i] = tmpArgs[i + 1]; // } // // cm.run(cs, args); // } // // } // // public static void registerSubCommand(KMSubCommand sc) { // if (getSubCommand(sc.getUsable().get(0), sc.getCommand()) == null) { // subCommands.add(sc); // } // } // // public static KMSubCommand getSubCommand(KMCommandType type, String command) { // for (KMSubCommand kms : subCommands) { // if (!kms.getUsable().contains(type)) { // continue; // } // // if (!kms.getCommand().equalsIgnoreCase(command)) { // if (kms.getAliases() == null ||kms.getAliases().isEmpty()) { // continue; // } // // for (String alias : kms.getAliases()) { // if (alias.equalsIgnoreCase(command)) { // return kms; // } // } // } else { // return kms; // } // } // // return null; // } // // public static ArrayList<KMSubCommand> getSubCommands() { // return subCommands; // } // } // // Path: src/net/diecode/killermoney/objects/KMSubCommand.java // public abstract class KMSubCommand { // // protected ArrayList<KMCommandType> usable; // protected String command; // protected KMPermission permission; // protected SenderType senderType; // protected int minArgs; // protected String usage; // protected ArrayList<String> aliases; // protected ArrayList<String> acceptableValues; // // public KMSubCommand(ArrayList<KMCommandType> usable, String command) { // this.usable = usable; // this.command = command; // } // // public ArrayList<KMCommandType> getUsable() { // return usable; // } // // public String getCommand() { // return command; // } // // public KMPermission getPermission() { // return permission; // } // // public SenderType getSenderType() { // return senderType; // } // // public int getMinArgs() { // return minArgs; // } // // public String getUsage() { // return usage; // } // // public ArrayList<String> getAliases() { // return aliases; // } // // public ArrayList<String> getAcceptableValues() { // return acceptableValues; // } // // public abstract void run(CommandSender cs, String[] args); // }
import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.managers.CommandManager; import net.diecode.killermoney.objects.KMSubCommand;
package net.diecode.killermoney.api; public class CommandAPI { /** * * @return subcommand */ public static KMSubCommand getSubCommand(KMCommandType type, String command) {
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/managers/CommandManager.java // public class CommandManager { // // private static ArrayList<KMSubCommand> subCommands = new ArrayList<>(); // // public static void onCommand(final CommandSender cs, Command cmd, String s, String[] tmpArgs, KMCommandType type) { // KMSubCommand cm = null; // // if (tmpArgs.length > 0) { // cm = getSubCommand(type, tmpArgs[0]); // } // // if (cm == null) { // cm = getSubCommand(type, "help"); // } // // if (cm != null) { // if (cm.getSenderType() == SenderType.PLAYER) { // if (!(cs instanceof Player)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_PLAYER); // // return; // } // } // // if (cm.getSenderType() == SenderType.CONSOLE) { // if (!(cs instanceof ConsoleCommandSender)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_CONSOLE); // // return; // } // } // // if (cm.getPermission() != null && !cs.hasPermission(cm.getPermission().get()) // && !cs.hasPermission(KMPermission.ADMIN.get())) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_YOU_HAVE_NOT_ENOUGH_PERMISSION, // cm.getPermission().get()); // // return; // } // // if (tmpArgs.length <= cm.getMinArgs()) { // // too few args // if (cm.getUsage() != null) { // cs.sendMessage(cm.getUsage()); // } // // return; // } // // String[] args = new String[tmpArgs.length - 1]; // // for (int i = 0; i < args.length; i++) { // args[i] = tmpArgs[i + 1]; // } // // cm.run(cs, args); // } // // } // // public static void registerSubCommand(KMSubCommand sc) { // if (getSubCommand(sc.getUsable().get(0), sc.getCommand()) == null) { // subCommands.add(sc); // } // } // // public static KMSubCommand getSubCommand(KMCommandType type, String command) { // for (KMSubCommand kms : subCommands) { // if (!kms.getUsable().contains(type)) { // continue; // } // // if (!kms.getCommand().equalsIgnoreCase(command)) { // if (kms.getAliases() == null ||kms.getAliases().isEmpty()) { // continue; // } // // for (String alias : kms.getAliases()) { // if (alias.equalsIgnoreCase(command)) { // return kms; // } // } // } else { // return kms; // } // } // // return null; // } // // public static ArrayList<KMSubCommand> getSubCommands() { // return subCommands; // } // } // // Path: src/net/diecode/killermoney/objects/KMSubCommand.java // public abstract class KMSubCommand { // // protected ArrayList<KMCommandType> usable; // protected String command; // protected KMPermission permission; // protected SenderType senderType; // protected int minArgs; // protected String usage; // protected ArrayList<String> aliases; // protected ArrayList<String> acceptableValues; // // public KMSubCommand(ArrayList<KMCommandType> usable, String command) { // this.usable = usable; // this.command = command; // } // // public ArrayList<KMCommandType> getUsable() { // return usable; // } // // public String getCommand() { // return command; // } // // public KMPermission getPermission() { // return permission; // } // // public SenderType getSenderType() { // return senderType; // } // // public int getMinArgs() { // return minArgs; // } // // public String getUsage() { // return usage; // } // // public ArrayList<String> getAliases() { // return aliases; // } // // public ArrayList<String> getAcceptableValues() { // return acceptableValues; // } // // public abstract void run(CommandSender cs, String[] args); // } // Path: src/net/diecode/killermoney/api/CommandAPI.java import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.managers.CommandManager; import net.diecode.killermoney.objects.KMSubCommand; package net.diecode.killermoney.api; public class CommandAPI { /** * * @return subcommand */ public static KMSubCommand getSubCommand(KMCommandType type, String command) {
return CommandManager.getSubCommand(type, command);
diecode/KillerMoney
src/net/diecode/killermoney/objects/CCommand.java
// Path: src/net/diecode/killermoney/Utils.java // public class Utils { // // public static boolean chanceGenerator(double chance) { // return (Math.random() * 100) < chance; // } // // public static double randomNumber(double min, double max) { // if (min == max) { // return min; // } // // double randomNumber = new Random().nextDouble(); // // if (max > min) { // return min + (max - min) * randomNumber; // } // // if (min > max) { // return max + (min - max) * randomNumber; // } // // return 0; // } // // public static int randomNumber(int min, int max) { // if (min == max) { // return min; // } // // return new Random().nextInt(max - min) + min; // } // // public static boolean inEntityEnum(String entity) { // for (EntityType et : EntityType.values()) { // if (et.name().equalsIgnoreCase(entity)) { // return true; // } // } // // return false; // } // // public static boolean inDivisionEnum(String division) { // for (DivisionMethod div : DivisionMethod.values()) { // if (div.name().equalsIgnoreCase(division)) { // return true; // } // } // // return false; // } // // public static boolean inRunMethodEnum(String runMethod) { // for (RunMethod rm : RunMethod.values()) { // if (rm.name().equalsIgnoreCase(runMethod)) { // return true; // } // } // // return false; // } // // public static double cleanChanceString(String str) { // double chance = Double.valueOf(str.replaceAll("%", "")); // // if (chance > 100) { // chance = 100; // } // // if (chance < 1) { // chance = 1; // } // // return chance; // } // // /* // public static int getMoneyMultiplier(Player p) { // int multiplier = 1; // // for (PermissionAttachmentInfo pai : p.getEffectivePermissions()) { // String perm = pai.getPermission().toLowerCase(); // // if (perm.contains(Permissions.MONEY_MULTIPLIER.getPerm())) { // perm = perm.replace(Permissions.MONEY_MULTIPLIER.getPerm() + ".", ""); // int tmpMultiplier = Integer.valueOf(perm); // // if (tmpMultiplier > multiplier) { // multiplier = tmpMultiplier; // } // } // } // // return multiplier; // } // */ // // public static String getRemainingTimeHumanFormat(int remainingTime) { // final int MINUTES_IN_DAY = 1440; // final int MINUTES_IN_HOUR = 60; // // int minutes = remainingTime; // // int days = minutes / MINUTES_IN_DAY; // minutes = minutes - (days * MINUTES_IN_DAY); // // int hours = minutes / MINUTES_IN_HOUR; // minutes = minutes - (hours * MINUTES_IN_HOUR); // // StringBuilder sb = new StringBuilder(); // // if (days > 0) { // if (days == 1) { // sb.append(days + " day"); // } else { // sb.append(days + " days"); // } // if (hours > 0 || minutes > 0) { // sb.append(", "); // } // } // // if (hours > 0) { // if (hours == 1) { // sb.append(hours + " hour"); // } else { // sb.append(hours + " hours"); // } // if (minutes > 0) { // sb.append(", "); // } // } // // if (minutes > 0) { // if (minutes == 1) { // sb.append(minutes + " minute"); // } else { // sb.append(minutes + " minutes"); // } // } // // if (sb.length() == 0) { // sb.append("< 1 minute"); // } // // return sb.toString(); // } // // public static boolean isValidInput(ArrayList<String> list, String value) { // for (String s : list) { // if (s.equalsIgnoreCase(value)) { // return true; // } // } // // return false; // } // // public static boolean getBoolean(String value) { // if (value.equalsIgnoreCase("on") || value.equalsIgnoreCase("true") // || value.equalsIgnoreCase("enable") || value.equalsIgnoreCase("1")) { // return true; // } // // return false; // } // // }
import net.diecode.killermoney.Utils; import java.util.HashMap; import java.util.UUID;
package net.diecode.killermoney.objects; public class CCommand { private String command; private String permission; private double chance; private int limit; private HashMap<UUID, Integer> limitCounter = new HashMap<UUID, Integer>(); public CCommand(String command, String permission, double chance, int limit) { this.command = command; this.permission = permission; this.chance = chance; this.limit = limit; } public String getCommand() { return command; } public String getPermission() { return permission; } public double getChance() { return chance; } public int getLimit() { return limit; } public boolean chanceGen() {
// Path: src/net/diecode/killermoney/Utils.java // public class Utils { // // public static boolean chanceGenerator(double chance) { // return (Math.random() * 100) < chance; // } // // public static double randomNumber(double min, double max) { // if (min == max) { // return min; // } // // double randomNumber = new Random().nextDouble(); // // if (max > min) { // return min + (max - min) * randomNumber; // } // // if (min > max) { // return max + (min - max) * randomNumber; // } // // return 0; // } // // public static int randomNumber(int min, int max) { // if (min == max) { // return min; // } // // return new Random().nextInt(max - min) + min; // } // // public static boolean inEntityEnum(String entity) { // for (EntityType et : EntityType.values()) { // if (et.name().equalsIgnoreCase(entity)) { // return true; // } // } // // return false; // } // // public static boolean inDivisionEnum(String division) { // for (DivisionMethod div : DivisionMethod.values()) { // if (div.name().equalsIgnoreCase(division)) { // return true; // } // } // // return false; // } // // public static boolean inRunMethodEnum(String runMethod) { // for (RunMethod rm : RunMethod.values()) { // if (rm.name().equalsIgnoreCase(runMethod)) { // return true; // } // } // // return false; // } // // public static double cleanChanceString(String str) { // double chance = Double.valueOf(str.replaceAll("%", "")); // // if (chance > 100) { // chance = 100; // } // // if (chance < 1) { // chance = 1; // } // // return chance; // } // // /* // public static int getMoneyMultiplier(Player p) { // int multiplier = 1; // // for (PermissionAttachmentInfo pai : p.getEffectivePermissions()) { // String perm = pai.getPermission().toLowerCase(); // // if (perm.contains(Permissions.MONEY_MULTIPLIER.getPerm())) { // perm = perm.replace(Permissions.MONEY_MULTIPLIER.getPerm() + ".", ""); // int tmpMultiplier = Integer.valueOf(perm); // // if (tmpMultiplier > multiplier) { // multiplier = tmpMultiplier; // } // } // } // // return multiplier; // } // */ // // public static String getRemainingTimeHumanFormat(int remainingTime) { // final int MINUTES_IN_DAY = 1440; // final int MINUTES_IN_HOUR = 60; // // int minutes = remainingTime; // // int days = minutes / MINUTES_IN_DAY; // minutes = minutes - (days * MINUTES_IN_DAY); // // int hours = minutes / MINUTES_IN_HOUR; // minutes = minutes - (hours * MINUTES_IN_HOUR); // // StringBuilder sb = new StringBuilder(); // // if (days > 0) { // if (days == 1) { // sb.append(days + " day"); // } else { // sb.append(days + " days"); // } // if (hours > 0 || minutes > 0) { // sb.append(", "); // } // } // // if (hours > 0) { // if (hours == 1) { // sb.append(hours + " hour"); // } else { // sb.append(hours + " hours"); // } // if (minutes > 0) { // sb.append(", "); // } // } // // if (minutes > 0) { // if (minutes == 1) { // sb.append(minutes + " minute"); // } else { // sb.append(minutes + " minutes"); // } // } // // if (sb.length() == 0) { // sb.append("< 1 minute"); // } // // return sb.toString(); // } // // public static boolean isValidInput(ArrayList<String> list, String value) { // for (String s : list) { // if (s.equalsIgnoreCase(value)) { // return true; // } // } // // return false; // } // // public static boolean getBoolean(String value) { // if (value.equalsIgnoreCase("on") || value.equalsIgnoreCase("true") // || value.equalsIgnoreCase("enable") || value.equalsIgnoreCase("1")) { // return true; // } // // return false; // } // // } // Path: src/net/diecode/killermoney/objects/CCommand.java import net.diecode.killermoney.Utils; import java.util.HashMap; import java.util.UUID; package net.diecode.killermoney.objects; public class CCommand { private String command; private String permission; private double chance; private int limit; private HashMap<UUID, Integer> limitCounter = new HashMap<UUID, Integer>(); public CCommand(String command, String permission, double chance, int limit) { this.command = command; this.permission = permission; this.chance = chance; this.limit = limit; } public String getCommand() { return command; } public String getPermission() { return permission; } public double getChance() { return chance; } public int getLimit() { return limit; } public boolean chanceGen() {
return Utils.chanceGenerator(this.chance);
diecode/KillerMoney
src/net/diecode/killermoney/events/KMMoneyProcessorEvent.java
// Path: src/net/diecode/killermoney/objects/EntityDamage.java // public class EntityDamage { // // private UUID puuid; // private BigDecimal damage; // private BigDecimal calculatedMoney; // // public EntityDamage(UUID puuid, BigDecimal damage) { // this.puuid = puuid; // this.damage = damage; // } // // public EntityDamage(UUID puuid, BigDecimal damage, BigDecimal money) { // this.puuid = puuid; // this.damage = damage; // this.calculatedMoney = money; // } // // public UUID getPlayerUUID() { // return puuid; // } // // public BigDecimal getDamage() { // return damage; // } // // public void increaseDamage(BigDecimal damage) { // this.damage = this.damage.add(damage); // } // // public BigDecimal getCalculatedMoney() { // return calculatedMoney; // } // // public void setCalculatedMoney(BigDecimal calculatedMoney) { // this.calculatedMoney = calculatedMoney; // } // } // // Path: src/net/diecode/killermoney/objects/MoneyProperties.java // public class MoneyProperties { // // private EntityType entityType; // private double chance; // private double minMoney; // private double maxMoney; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public MoneyProperties(EntityType entityType, double chance, double minMoney, double maxMoney, String permission, // int limit, DivisionMethod divisionMethod, boolean enabled) { // this.entityType = entityType; // this.chance = chance; // this.minMoney = minMoney; // this.maxMoney = maxMoney; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public EntityType getEntityType() { // return entityType; // } // // public double getChance() { // return chance; // } // // public double getMinMoney() { // return minMoney; // } // // public double getMaxMoney() { // return maxMoney; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public boolean isEnabled() { // return enabled; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player != null) { // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // } // // BigDecimal limit = getLimit(player); // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.compareTo(limit) >= 0) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // // public BigDecimal getLimit(Player player) { // if (player == null) { // return new BigDecimal(limit); // } // // return new BigDecimal(limit * MultiplierHandler.getPermBasedMoneyLimitMultiplier(player)) // .setScale(DefaultConfig.getDecimalPlaces(), BigDecimal.ROUND_HALF_EVEN); // } // }
import net.diecode.killermoney.objects.EntityDamage; import net.diecode.killermoney.objects.MoneyProperties; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.util.ArrayList;
package net.diecode.killermoney.events; public class KMMoneyProcessorEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList();
// Path: src/net/diecode/killermoney/objects/EntityDamage.java // public class EntityDamage { // // private UUID puuid; // private BigDecimal damage; // private BigDecimal calculatedMoney; // // public EntityDamage(UUID puuid, BigDecimal damage) { // this.puuid = puuid; // this.damage = damage; // } // // public EntityDamage(UUID puuid, BigDecimal damage, BigDecimal money) { // this.puuid = puuid; // this.damage = damage; // this.calculatedMoney = money; // } // // public UUID getPlayerUUID() { // return puuid; // } // // public BigDecimal getDamage() { // return damage; // } // // public void increaseDamage(BigDecimal damage) { // this.damage = this.damage.add(damage); // } // // public BigDecimal getCalculatedMoney() { // return calculatedMoney; // } // // public void setCalculatedMoney(BigDecimal calculatedMoney) { // this.calculatedMoney = calculatedMoney; // } // } // // Path: src/net/diecode/killermoney/objects/MoneyProperties.java // public class MoneyProperties { // // private EntityType entityType; // private double chance; // private double minMoney; // private double maxMoney; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public MoneyProperties(EntityType entityType, double chance, double minMoney, double maxMoney, String permission, // int limit, DivisionMethod divisionMethod, boolean enabled) { // this.entityType = entityType; // this.chance = chance; // this.minMoney = minMoney; // this.maxMoney = maxMoney; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public EntityType getEntityType() { // return entityType; // } // // public double getChance() { // return chance; // } // // public double getMinMoney() { // return minMoney; // } // // public double getMaxMoney() { // return maxMoney; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public boolean isEnabled() { // return enabled; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player != null) { // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // } // // BigDecimal limit = getLimit(player); // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.compareTo(limit) >= 0) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // // public BigDecimal getLimit(Player player) { // if (player == null) { // return new BigDecimal(limit); // } // // return new BigDecimal(limit * MultiplierHandler.getPermBasedMoneyLimitMultiplier(player)) // .setScale(DefaultConfig.getDecimalPlaces(), BigDecimal.ROUND_HALF_EVEN); // } // } // Path: src/net/diecode/killermoney/events/KMMoneyProcessorEvent.java import net.diecode.killermoney.objects.EntityDamage; import net.diecode.killermoney.objects.MoneyProperties; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.util.ArrayList; package net.diecode.killermoney.events; public class KMMoneyProcessorEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList();
private MoneyProperties moneyProperties;
diecode/KillerMoney
src/net/diecode/killermoney/events/KMMoneyProcessorEvent.java
// Path: src/net/diecode/killermoney/objects/EntityDamage.java // public class EntityDamage { // // private UUID puuid; // private BigDecimal damage; // private BigDecimal calculatedMoney; // // public EntityDamage(UUID puuid, BigDecimal damage) { // this.puuid = puuid; // this.damage = damage; // } // // public EntityDamage(UUID puuid, BigDecimal damage, BigDecimal money) { // this.puuid = puuid; // this.damage = damage; // this.calculatedMoney = money; // } // // public UUID getPlayerUUID() { // return puuid; // } // // public BigDecimal getDamage() { // return damage; // } // // public void increaseDamage(BigDecimal damage) { // this.damage = this.damage.add(damage); // } // // public BigDecimal getCalculatedMoney() { // return calculatedMoney; // } // // public void setCalculatedMoney(BigDecimal calculatedMoney) { // this.calculatedMoney = calculatedMoney; // } // } // // Path: src/net/diecode/killermoney/objects/MoneyProperties.java // public class MoneyProperties { // // private EntityType entityType; // private double chance; // private double minMoney; // private double maxMoney; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public MoneyProperties(EntityType entityType, double chance, double minMoney, double maxMoney, String permission, // int limit, DivisionMethod divisionMethod, boolean enabled) { // this.entityType = entityType; // this.chance = chance; // this.minMoney = minMoney; // this.maxMoney = maxMoney; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public EntityType getEntityType() { // return entityType; // } // // public double getChance() { // return chance; // } // // public double getMinMoney() { // return minMoney; // } // // public double getMaxMoney() { // return maxMoney; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public boolean isEnabled() { // return enabled; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player != null) { // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // } // // BigDecimal limit = getLimit(player); // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.compareTo(limit) >= 0) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // // public BigDecimal getLimit(Player player) { // if (player == null) { // return new BigDecimal(limit); // } // // return new BigDecimal(limit * MultiplierHandler.getPermBasedMoneyLimitMultiplier(player)) // .setScale(DefaultConfig.getDecimalPlaces(), BigDecimal.ROUND_HALF_EVEN); // } // }
import net.diecode.killermoney.objects.EntityDamage; import net.diecode.killermoney.objects.MoneyProperties; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.util.ArrayList;
package net.diecode.killermoney.events; public class KMMoneyProcessorEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private MoneyProperties moneyProperties;
// Path: src/net/diecode/killermoney/objects/EntityDamage.java // public class EntityDamage { // // private UUID puuid; // private BigDecimal damage; // private BigDecimal calculatedMoney; // // public EntityDamage(UUID puuid, BigDecimal damage) { // this.puuid = puuid; // this.damage = damage; // } // // public EntityDamage(UUID puuid, BigDecimal damage, BigDecimal money) { // this.puuid = puuid; // this.damage = damage; // this.calculatedMoney = money; // } // // public UUID getPlayerUUID() { // return puuid; // } // // public BigDecimal getDamage() { // return damage; // } // // public void increaseDamage(BigDecimal damage) { // this.damage = this.damage.add(damage); // } // // public BigDecimal getCalculatedMoney() { // return calculatedMoney; // } // // public void setCalculatedMoney(BigDecimal calculatedMoney) { // this.calculatedMoney = calculatedMoney; // } // } // // Path: src/net/diecode/killermoney/objects/MoneyProperties.java // public class MoneyProperties { // // private EntityType entityType; // private double chance; // private double minMoney; // private double maxMoney; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public MoneyProperties(EntityType entityType, double chance, double minMoney, double maxMoney, String permission, // int limit, DivisionMethod divisionMethod, boolean enabled) { // this.entityType = entityType; // this.chance = chance; // this.minMoney = minMoney; // this.maxMoney = maxMoney; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public EntityType getEntityType() { // return entityType; // } // // public double getChance() { // return chance; // } // // public double getMinMoney() { // return minMoney; // } // // public double getMaxMoney() { // return maxMoney; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public boolean isEnabled() { // return enabled; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player != null) { // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // } // // BigDecimal limit = getLimit(player); // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.compareTo(limit) >= 0) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // // public BigDecimal getLimit(Player player) { // if (player == null) { // return new BigDecimal(limit); // } // // return new BigDecimal(limit * MultiplierHandler.getPermBasedMoneyLimitMultiplier(player)) // .setScale(DefaultConfig.getDecimalPlaces(), BigDecimal.ROUND_HALF_EVEN); // } // } // Path: src/net/diecode/killermoney/events/KMMoneyProcessorEvent.java import net.diecode.killermoney.objects.EntityDamage; import net.diecode.killermoney.objects.MoneyProperties; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.util.ArrayList; package net.diecode.killermoney.events; public class KMMoneyProcessorEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private MoneyProperties moneyProperties;
private ArrayList<EntityDamage> damagers;
diecode/KillerMoney
src/net/diecode/killermoney/configs/SuperConfig.java
// Path: src/net/diecode/killermoney/BukkitMain.java // public class BukkitMain extends JavaPlugin { // // private static BukkitMain instance; // private static Metrics metrics; // // private static Economy economy; // private static MobArenaHandler mobArenaHandler; // private static Updater updater; // // private void initMetrics() { // metrics = new Metrics(this); // metrics.addCustomChart(new Metrics.SimplePie("used_message_method") { // @Override // public String getValue() { // return DefaultConfig.getMessageMethod().name().toUpperCase(); // } // }); // // metrics.addCustomChart(new Metrics.SimplePie("used_money_item_drop") { // @Override // public String getValue() { // return DefaultConfig.isMoneyItemDropEnabled() ? "Enabled" : "Disabled"; // } // }); // } // // private boolean initEconomy() { // RegisteredServiceProvider<Economy> economyProvider = // Bukkit.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); // // if (economyProvider != null) { // economy = economyProvider.getProvider(); // } // // return (economy != null); // } // // private void hookMobArena() { // if (Bukkit.getPluginManager().getPlugin("MobArena") != null) { // mobArenaHandler = new MobArenaHandler(); // // Logger.info("MobArena hooked"); // } else { // Logger.info("MobArena not found"); // } // } // // @Override // public void onEnable() { // instance = this; // // ConfigManager.init(); // // updater = new Updater(); // // initMetrics(); // // if (!initEconomy()) { // Logger.warning("Vault or economy plugin not found! Money reward disabled."); // } // // if (DefaultConfig.isHookMobArena()) { // hookMobArena(); // } // // getCommand("km").setExecutor(new KMCommand()); // getCommand("kmadmin").setExecutor(new KMAdminCommand()); // // Bukkit.getPluginManager().registerEvents(new EntityManager(), this); // Bukkit.getPluginManager().registerEvents(new MoneyHandler(), this); // Bukkit.getPluginManager().registerEvents(new CItemHandler(), this); // Bukkit.getPluginManager().registerEvents(new CCommandHandler(), this); // Bukkit.getPluginManager().registerEvents(new CExpHandler(), this); // Bukkit.getPluginManager().registerEvents(new MessageHandler(), this); // Bukkit.getPluginManager().registerEvents(new CashTransferHandler(), this); // Bukkit.getPluginManager().registerEvents(new AntiFarmingHandler(), this); // Bukkit.getPluginManager().registerEvents(new LimitHandler(), this); // Bukkit.getPluginManager().registerEvents(new MultiplierHandler(), this); // Bukkit.getPluginManager().registerEvents(new KMPlayerManager(), this); // Bukkit.getPluginManager().registerEvents(updater, this); // // if (DefaultConfig.isCheckUpdate()) { // getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() { // @Override // public void run() { // if (!Updater.isUpdateAvailable()) { // updater.query(); // } // } // }, 20L, 20L * 60 * 60 * 24); // } // // for (Player p : Bukkit.getOnlinePlayers()) { // UUID pUUID = p.getUniqueId(); // // if (!KMPlayerManager.getKMPlayers().containsKey(pUUID)) { // KMPlayerManager.getKMPlayers().put(pUUID, new KMPlayer(p)); // } // } // } // // @Override // public void onDisable() { // instance = null; // updater = null; // } // // public static BukkitMain getInstance() { // return instance; // } // // public static Economy getEconomy() { // return economy; // } // // public static MobArenaHandler getMobArenaHandler() { // return mobArenaHandler; // } // }
import net.diecode.killermoney.BukkitMain; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; import java.nio.file.Files;
package net.diecode.killermoney.configs; public abstract class SuperConfig { private String fileName; private File file; private FileConfiguration config; public SuperConfig(String fileName) { this.fileName = fileName;
// Path: src/net/diecode/killermoney/BukkitMain.java // public class BukkitMain extends JavaPlugin { // // private static BukkitMain instance; // private static Metrics metrics; // // private static Economy economy; // private static MobArenaHandler mobArenaHandler; // private static Updater updater; // // private void initMetrics() { // metrics = new Metrics(this); // metrics.addCustomChart(new Metrics.SimplePie("used_message_method") { // @Override // public String getValue() { // return DefaultConfig.getMessageMethod().name().toUpperCase(); // } // }); // // metrics.addCustomChart(new Metrics.SimplePie("used_money_item_drop") { // @Override // public String getValue() { // return DefaultConfig.isMoneyItemDropEnabled() ? "Enabled" : "Disabled"; // } // }); // } // // private boolean initEconomy() { // RegisteredServiceProvider<Economy> economyProvider = // Bukkit.getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); // // if (economyProvider != null) { // economy = economyProvider.getProvider(); // } // // return (economy != null); // } // // private void hookMobArena() { // if (Bukkit.getPluginManager().getPlugin("MobArena") != null) { // mobArenaHandler = new MobArenaHandler(); // // Logger.info("MobArena hooked"); // } else { // Logger.info("MobArena not found"); // } // } // // @Override // public void onEnable() { // instance = this; // // ConfigManager.init(); // // updater = new Updater(); // // initMetrics(); // // if (!initEconomy()) { // Logger.warning("Vault or economy plugin not found! Money reward disabled."); // } // // if (DefaultConfig.isHookMobArena()) { // hookMobArena(); // } // // getCommand("km").setExecutor(new KMCommand()); // getCommand("kmadmin").setExecutor(new KMAdminCommand()); // // Bukkit.getPluginManager().registerEvents(new EntityManager(), this); // Bukkit.getPluginManager().registerEvents(new MoneyHandler(), this); // Bukkit.getPluginManager().registerEvents(new CItemHandler(), this); // Bukkit.getPluginManager().registerEvents(new CCommandHandler(), this); // Bukkit.getPluginManager().registerEvents(new CExpHandler(), this); // Bukkit.getPluginManager().registerEvents(new MessageHandler(), this); // Bukkit.getPluginManager().registerEvents(new CashTransferHandler(), this); // Bukkit.getPluginManager().registerEvents(new AntiFarmingHandler(), this); // Bukkit.getPluginManager().registerEvents(new LimitHandler(), this); // Bukkit.getPluginManager().registerEvents(new MultiplierHandler(), this); // Bukkit.getPluginManager().registerEvents(new KMPlayerManager(), this); // Bukkit.getPluginManager().registerEvents(updater, this); // // if (DefaultConfig.isCheckUpdate()) { // getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() { // @Override // public void run() { // if (!Updater.isUpdateAvailable()) { // updater.query(); // } // } // }, 20L, 20L * 60 * 60 * 24); // } // // for (Player p : Bukkit.getOnlinePlayers()) { // UUID pUUID = p.getUniqueId(); // // if (!KMPlayerManager.getKMPlayers().containsKey(pUUID)) { // KMPlayerManager.getKMPlayers().put(pUUID, new KMPlayer(p)); // } // } // } // // @Override // public void onDisable() { // instance = null; // updater = null; // } // // public static BukkitMain getInstance() { // return instance; // } // // public static Economy getEconomy() { // return economy; // } // // public static MobArenaHandler getMobArenaHandler() { // return mobArenaHandler; // } // } // Path: src/net/diecode/killermoney/configs/SuperConfig.java import net.diecode.killermoney.BukkitMain; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; import java.io.IOException; import java.nio.file.Files; package net.diecode.killermoney.configs; public abstract class SuperConfig { private String fileName; private File file; private FileConfiguration config; public SuperConfig(String fileName) { this.fileName = fileName;
this.file = new File(BukkitMain.getInstance().getDataFolder(), this.fileName);
diecode/KillerMoney
src/net/diecode/killermoney/commands/KMAdminCommand.java
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/managers/CommandManager.java // public class CommandManager { // // private static ArrayList<KMSubCommand> subCommands = new ArrayList<>(); // // public static void onCommand(final CommandSender cs, Command cmd, String s, String[] tmpArgs, KMCommandType type) { // KMSubCommand cm = null; // // if (tmpArgs.length > 0) { // cm = getSubCommand(type, tmpArgs[0]); // } // // if (cm == null) { // cm = getSubCommand(type, "help"); // } // // if (cm != null) { // if (cm.getSenderType() == SenderType.PLAYER) { // if (!(cs instanceof Player)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_PLAYER); // // return; // } // } // // if (cm.getSenderType() == SenderType.CONSOLE) { // if (!(cs instanceof ConsoleCommandSender)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_CONSOLE); // // return; // } // } // // if (cm.getPermission() != null && !cs.hasPermission(cm.getPermission().get()) // && !cs.hasPermission(KMPermission.ADMIN.get())) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_YOU_HAVE_NOT_ENOUGH_PERMISSION, // cm.getPermission().get()); // // return; // } // // if (tmpArgs.length <= cm.getMinArgs()) { // // too few args // if (cm.getUsage() != null) { // cs.sendMessage(cm.getUsage()); // } // // return; // } // // String[] args = new String[tmpArgs.length - 1]; // // for (int i = 0; i < args.length; i++) { // args[i] = tmpArgs[i + 1]; // } // // cm.run(cs, args); // } // // } // // public static void registerSubCommand(KMSubCommand sc) { // if (getSubCommand(sc.getUsable().get(0), sc.getCommand()) == null) { // subCommands.add(sc); // } // } // // public static KMSubCommand getSubCommand(KMCommandType type, String command) { // for (KMSubCommand kms : subCommands) { // if (!kms.getUsable().contains(type)) { // continue; // } // // if (!kms.getCommand().equalsIgnoreCase(command)) { // if (kms.getAliases() == null ||kms.getAliases().isEmpty()) { // continue; // } // // for (String alias : kms.getAliases()) { // if (alias.equalsIgnoreCase(command)) { // return kms; // } // } // } else { // return kms; // } // } // // return null; // } // // public static ArrayList<KMSubCommand> getSubCommands() { // return subCommands; // } // }
import net.diecode.killermoney.commands.subcommands.kmadmin.*; import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.managers.CommandManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender;
package net.diecode.killermoney.commands; public class KMAdminCommand implements CommandExecutor { public KMAdminCommand() {
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/managers/CommandManager.java // public class CommandManager { // // private static ArrayList<KMSubCommand> subCommands = new ArrayList<>(); // // public static void onCommand(final CommandSender cs, Command cmd, String s, String[] tmpArgs, KMCommandType type) { // KMSubCommand cm = null; // // if (tmpArgs.length > 0) { // cm = getSubCommand(type, tmpArgs[0]); // } // // if (cm == null) { // cm = getSubCommand(type, "help"); // } // // if (cm != null) { // if (cm.getSenderType() == SenderType.PLAYER) { // if (!(cs instanceof Player)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_PLAYER); // // return; // } // } // // if (cm.getSenderType() == SenderType.CONSOLE) { // if (!(cs instanceof ConsoleCommandSender)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_CONSOLE); // // return; // } // } // // if (cm.getPermission() != null && !cs.hasPermission(cm.getPermission().get()) // && !cs.hasPermission(KMPermission.ADMIN.get())) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_YOU_HAVE_NOT_ENOUGH_PERMISSION, // cm.getPermission().get()); // // return; // } // // if (tmpArgs.length <= cm.getMinArgs()) { // // too few args // if (cm.getUsage() != null) { // cs.sendMessage(cm.getUsage()); // } // // return; // } // // String[] args = new String[tmpArgs.length - 1]; // // for (int i = 0; i < args.length; i++) { // args[i] = tmpArgs[i + 1]; // } // // cm.run(cs, args); // } // // } // // public static void registerSubCommand(KMSubCommand sc) { // if (getSubCommand(sc.getUsable().get(0), sc.getCommand()) == null) { // subCommands.add(sc); // } // } // // public static KMSubCommand getSubCommand(KMCommandType type, String command) { // for (KMSubCommand kms : subCommands) { // if (!kms.getUsable().contains(type)) { // continue; // } // // if (!kms.getCommand().equalsIgnoreCase(command)) { // if (kms.getAliases() == null ||kms.getAliases().isEmpty()) { // continue; // } // // for (String alias : kms.getAliases()) { // if (alias.equalsIgnoreCase(command)) { // return kms; // } // } // } else { // return kms; // } // } // // return null; // } // // public static ArrayList<KMSubCommand> getSubCommands() { // return subCommands; // } // } // Path: src/net/diecode/killermoney/commands/KMAdminCommand.java import net.diecode.killermoney.commands.subcommands.kmadmin.*; import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.managers.CommandManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; package net.diecode.killermoney.commands; public class KMAdminCommand implements CommandExecutor { public KMAdminCommand() {
CommandManager.registerSubCommand(new HelpCommand("help"));
diecode/KillerMoney
src/net/diecode/killermoney/commands/KMAdminCommand.java
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/managers/CommandManager.java // public class CommandManager { // // private static ArrayList<KMSubCommand> subCommands = new ArrayList<>(); // // public static void onCommand(final CommandSender cs, Command cmd, String s, String[] tmpArgs, KMCommandType type) { // KMSubCommand cm = null; // // if (tmpArgs.length > 0) { // cm = getSubCommand(type, tmpArgs[0]); // } // // if (cm == null) { // cm = getSubCommand(type, "help"); // } // // if (cm != null) { // if (cm.getSenderType() == SenderType.PLAYER) { // if (!(cs instanceof Player)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_PLAYER); // // return; // } // } // // if (cm.getSenderType() == SenderType.CONSOLE) { // if (!(cs instanceof ConsoleCommandSender)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_CONSOLE); // // return; // } // } // // if (cm.getPermission() != null && !cs.hasPermission(cm.getPermission().get()) // && !cs.hasPermission(KMPermission.ADMIN.get())) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_YOU_HAVE_NOT_ENOUGH_PERMISSION, // cm.getPermission().get()); // // return; // } // // if (tmpArgs.length <= cm.getMinArgs()) { // // too few args // if (cm.getUsage() != null) { // cs.sendMessage(cm.getUsage()); // } // // return; // } // // String[] args = new String[tmpArgs.length - 1]; // // for (int i = 0; i < args.length; i++) { // args[i] = tmpArgs[i + 1]; // } // // cm.run(cs, args); // } // // } // // public static void registerSubCommand(KMSubCommand sc) { // if (getSubCommand(sc.getUsable().get(0), sc.getCommand()) == null) { // subCommands.add(sc); // } // } // // public static KMSubCommand getSubCommand(KMCommandType type, String command) { // for (KMSubCommand kms : subCommands) { // if (!kms.getUsable().contains(type)) { // continue; // } // // if (!kms.getCommand().equalsIgnoreCase(command)) { // if (kms.getAliases() == null ||kms.getAliases().isEmpty()) { // continue; // } // // for (String alias : kms.getAliases()) { // if (alias.equalsIgnoreCase(command)) { // return kms; // } // } // } else { // return kms; // } // } // // return null; // } // // public static ArrayList<KMSubCommand> getSubCommands() { // return subCommands; // } // }
import net.diecode.killermoney.commands.subcommands.kmadmin.*; import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.managers.CommandManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender;
package net.diecode.killermoney.commands; public class KMAdminCommand implements CommandExecutor { public KMAdminCommand() { CommandManager.registerSubCommand(new HelpCommand("help")); CommandManager.registerSubCommand(new LimitCommand("limit")); CommandManager.registerSubCommand(new MultiplierCommand("multiplier")); CommandManager.registerSubCommand(new ReloadCommand("reload")); } @Override public boolean onCommand(final CommandSender cs, Command cmd, String s, String[] tmpArgs) { if (tmpArgs.length == 0) { HelpCommand.showHelp(cs); return true; }
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/managers/CommandManager.java // public class CommandManager { // // private static ArrayList<KMSubCommand> subCommands = new ArrayList<>(); // // public static void onCommand(final CommandSender cs, Command cmd, String s, String[] tmpArgs, KMCommandType type) { // KMSubCommand cm = null; // // if (tmpArgs.length > 0) { // cm = getSubCommand(type, tmpArgs[0]); // } // // if (cm == null) { // cm = getSubCommand(type, "help"); // } // // if (cm != null) { // if (cm.getSenderType() == SenderType.PLAYER) { // if (!(cs instanceof Player)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_PLAYER); // // return; // } // } // // if (cm.getSenderType() == SenderType.CONSOLE) { // if (!(cs instanceof ConsoleCommandSender)) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_THIS_COMMAND_ONLY_USABLE_BY_CONSOLE); // // return; // } // } // // if (cm.getPermission() != null && !cs.hasPermission(cm.getPermission().get()) // && !cs.hasPermission(KMPermission.ADMIN.get())) { // LanguageManager.send(cs, LanguageString.COMMANDS_SHARED_YOU_HAVE_NOT_ENOUGH_PERMISSION, // cm.getPermission().get()); // // return; // } // // if (tmpArgs.length <= cm.getMinArgs()) { // // too few args // if (cm.getUsage() != null) { // cs.sendMessage(cm.getUsage()); // } // // return; // } // // String[] args = new String[tmpArgs.length - 1]; // // for (int i = 0; i < args.length; i++) { // args[i] = tmpArgs[i + 1]; // } // // cm.run(cs, args); // } // // } // // public static void registerSubCommand(KMSubCommand sc) { // if (getSubCommand(sc.getUsable().get(0), sc.getCommand()) == null) { // subCommands.add(sc); // } // } // // public static KMSubCommand getSubCommand(KMCommandType type, String command) { // for (KMSubCommand kms : subCommands) { // if (!kms.getUsable().contains(type)) { // continue; // } // // if (!kms.getCommand().equalsIgnoreCase(command)) { // if (kms.getAliases() == null ||kms.getAliases().isEmpty()) { // continue; // } // // for (String alias : kms.getAliases()) { // if (alias.equalsIgnoreCase(command)) { // return kms; // } // } // } else { // return kms; // } // } // // return null; // } // // public static ArrayList<KMSubCommand> getSubCommands() { // return subCommands; // } // } // Path: src/net/diecode/killermoney/commands/KMAdminCommand.java import net.diecode.killermoney.commands.subcommands.kmadmin.*; import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.managers.CommandManager; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; package net.diecode.killermoney.commands; public class KMAdminCommand implements CommandExecutor { public KMAdminCommand() { CommandManager.registerSubCommand(new HelpCommand("help")); CommandManager.registerSubCommand(new LimitCommand("limit")); CommandManager.registerSubCommand(new MultiplierCommand("multiplier")); CommandManager.registerSubCommand(new ReloadCommand("reload")); } @Override public boolean onCommand(final CommandSender cs, Command cmd, String s, String[] tmpArgs) { if (tmpArgs.length == 0) { HelpCommand.showHelp(cs); return true; }
CommandManager.onCommand(cs, cmd, s, tmpArgs, KMCommandType.KM_ADMIN);
diecode/KillerMoney
src/net/diecode/killermoney/events/KMCItemDropEvent.java
// Path: src/net/diecode/killermoney/objects/CItem.java // public class CItem { // // private ItemStack itemStack; // private int minAmount; // private int maxAmount; // private double chance; // private String permission; // private int limit; // private HashMap<UUID, Integer> limitCounter = new HashMap<UUID, Integer>(); // // public CItem(ItemStack itemStack, int minAmount, int maxAmount, double chance, String permission, int limit) { // this.itemStack = itemStack; // this.minAmount = minAmount; // this.maxAmount = maxAmount; // this.chance = chance; // this.permission = permission; // this.limit = limit; // } // // public ItemStack getItemStack() { // return itemStack; // } // // public int getMinAmount() { // return minAmount; // } // // public int getMaxAmount() { // return maxAmount; // } // // public double getChance() { // return chance; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public HashMap<UUID, Integer> getLimitCounter() { // return limitCounter; // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // if (current >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, int counter) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // limitCounter.put(uuid, current + counter); // } else { // limitCounter.put(uuid, counter); // } // } // // public int getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return 0; // } // }
import net.diecode.killermoney.objects.CItem; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack;
package net.diecode.killermoney.events; public class KMCItemDropEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList();
// Path: src/net/diecode/killermoney/objects/CItem.java // public class CItem { // // private ItemStack itemStack; // private int minAmount; // private int maxAmount; // private double chance; // private String permission; // private int limit; // private HashMap<UUID, Integer> limitCounter = new HashMap<UUID, Integer>(); // // public CItem(ItemStack itemStack, int minAmount, int maxAmount, double chance, String permission, int limit) { // this.itemStack = itemStack; // this.minAmount = minAmount; // this.maxAmount = maxAmount; // this.chance = chance; // this.permission = permission; // this.limit = limit; // } // // public ItemStack getItemStack() { // return itemStack; // } // // public int getMinAmount() { // return minAmount; // } // // public int getMaxAmount() { // return maxAmount; // } // // public double getChance() { // return chance; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public HashMap<UUID, Integer> getLimitCounter() { // return limitCounter; // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // if (current >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, int counter) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // int current = limitCounter.get(uuid); // // limitCounter.put(uuid, current + counter); // } else { // limitCounter.put(uuid, counter); // } // } // // public int getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return 0; // } // } // Path: src/net/diecode/killermoney/events/KMCItemDropEvent.java import net.diecode.killermoney.objects.CItem; import org.bukkit.Location; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; package net.diecode.killermoney.events; public class KMCItemDropEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList();
private CItem cItem;
diecode/KillerMoney
src/net/diecode/killermoney/objects/KMSubCommand.java
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/enums/KMPermission.java // public enum KMPermission { // // ADMIN("admin"), // MONEY_MULTIPLIER("money.multiplier"), // // LIMIT_MONEY_MULTIPLIER("moneylimit.multiplier"), // //LIMIT_ITEM_MULTIPLIER("itemlimit.multiplier"), // //LIMIT_COMMAND_MULTIPLIER("commandlimit.multiplier"), // // BYPASS_MONEY_LIMIT("bypass.moneylimit"), // BYPASS_ITEM_LIMIT("bypass.itemlimit"), // BYPASS_COMMAND_LIMIT("bypass.commandlimit"), // BYPASS_MONEY_LIMIT_CASH_TRANSFER("bypass.cashtransferlimit"); // // private String perm; // // KMPermission(String perm) { // this.perm = perm; // } // // public String get() { // return "km." + perm; // } // // } // // Path: src/net/diecode/killermoney/enums/SenderType.java // public enum SenderType { // // PLAYER, CONSOLE, ANYONE // // }
import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.enums.KMPermission; import net.diecode.killermoney.enums.SenderType; import org.bukkit.command.CommandSender; import java.util.ArrayList;
package net.diecode.killermoney.objects; public abstract class KMSubCommand { protected ArrayList<KMCommandType> usable; protected String command;
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/enums/KMPermission.java // public enum KMPermission { // // ADMIN("admin"), // MONEY_MULTIPLIER("money.multiplier"), // // LIMIT_MONEY_MULTIPLIER("moneylimit.multiplier"), // //LIMIT_ITEM_MULTIPLIER("itemlimit.multiplier"), // //LIMIT_COMMAND_MULTIPLIER("commandlimit.multiplier"), // // BYPASS_MONEY_LIMIT("bypass.moneylimit"), // BYPASS_ITEM_LIMIT("bypass.itemlimit"), // BYPASS_COMMAND_LIMIT("bypass.commandlimit"), // BYPASS_MONEY_LIMIT_CASH_TRANSFER("bypass.cashtransferlimit"); // // private String perm; // // KMPermission(String perm) { // this.perm = perm; // } // // public String get() { // return "km." + perm; // } // // } // // Path: src/net/diecode/killermoney/enums/SenderType.java // public enum SenderType { // // PLAYER, CONSOLE, ANYONE // // } // Path: src/net/diecode/killermoney/objects/KMSubCommand.java import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.enums.KMPermission; import net.diecode.killermoney.enums.SenderType; import org.bukkit.command.CommandSender; import java.util.ArrayList; package net.diecode.killermoney.objects; public abstract class KMSubCommand { protected ArrayList<KMCommandType> usable; protected String command;
protected KMPermission permission;
diecode/KillerMoney
src/net/diecode/killermoney/objects/KMSubCommand.java
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/enums/KMPermission.java // public enum KMPermission { // // ADMIN("admin"), // MONEY_MULTIPLIER("money.multiplier"), // // LIMIT_MONEY_MULTIPLIER("moneylimit.multiplier"), // //LIMIT_ITEM_MULTIPLIER("itemlimit.multiplier"), // //LIMIT_COMMAND_MULTIPLIER("commandlimit.multiplier"), // // BYPASS_MONEY_LIMIT("bypass.moneylimit"), // BYPASS_ITEM_LIMIT("bypass.itemlimit"), // BYPASS_COMMAND_LIMIT("bypass.commandlimit"), // BYPASS_MONEY_LIMIT_CASH_TRANSFER("bypass.cashtransferlimit"); // // private String perm; // // KMPermission(String perm) { // this.perm = perm; // } // // public String get() { // return "km." + perm; // } // // } // // Path: src/net/diecode/killermoney/enums/SenderType.java // public enum SenderType { // // PLAYER, CONSOLE, ANYONE // // }
import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.enums.KMPermission; import net.diecode.killermoney.enums.SenderType; import org.bukkit.command.CommandSender; import java.util.ArrayList;
package net.diecode.killermoney.objects; public abstract class KMSubCommand { protected ArrayList<KMCommandType> usable; protected String command; protected KMPermission permission;
// Path: src/net/diecode/killermoney/enums/KMCommandType.java // public enum KMCommandType { // // KM, KM_ADMIN // // } // // Path: src/net/diecode/killermoney/enums/KMPermission.java // public enum KMPermission { // // ADMIN("admin"), // MONEY_MULTIPLIER("money.multiplier"), // // LIMIT_MONEY_MULTIPLIER("moneylimit.multiplier"), // //LIMIT_ITEM_MULTIPLIER("itemlimit.multiplier"), // //LIMIT_COMMAND_MULTIPLIER("commandlimit.multiplier"), // // BYPASS_MONEY_LIMIT("bypass.moneylimit"), // BYPASS_ITEM_LIMIT("bypass.itemlimit"), // BYPASS_COMMAND_LIMIT("bypass.commandlimit"), // BYPASS_MONEY_LIMIT_CASH_TRANSFER("bypass.cashtransferlimit"); // // private String perm; // // KMPermission(String perm) { // this.perm = perm; // } // // public String get() { // return "km." + perm; // } // // } // // Path: src/net/diecode/killermoney/enums/SenderType.java // public enum SenderType { // // PLAYER, CONSOLE, ANYONE // // } // Path: src/net/diecode/killermoney/objects/KMSubCommand.java import net.diecode.killermoney.enums.KMCommandType; import net.diecode.killermoney.enums.KMPermission; import net.diecode.killermoney.enums.SenderType; import org.bukkit.command.CommandSender; import java.util.ArrayList; package net.diecode.killermoney.objects; public abstract class KMSubCommand { protected ArrayList<KMCommandType> usable; protected String command; protected KMPermission permission;
protected SenderType senderType;
diecode/KillerMoney
src/net/diecode/killermoney/events/KMCashTransferProcessorEvent.java
// Path: src/net/diecode/killermoney/objects/CashTransferProperties.java // public class CashTransferProperties { // // private double percent; // private int maxAmount; // private double chance; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public CashTransferProperties(double percent, int maxAmount, double chance, String permission, int limit, // DivisionMethod divisionMethod, boolean enabled) { // this.percent = percent; // this.maxAmount = maxAmount; // this.chance = chance; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public double getPercent() { // return percent; // } // // public int getMaxAmount() { // return maxAmount; // } // // public double getChance() { // return chance; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean isEnabled() { // return enabled; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.doubleValue() >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // } // // Path: src/net/diecode/killermoney/objects/EntityDamage.java // public class EntityDamage { // // private UUID puuid; // private BigDecimal damage; // private BigDecimal calculatedMoney; // // public EntityDamage(UUID puuid, BigDecimal damage) { // this.puuid = puuid; // this.damage = damage; // } // // public EntityDamage(UUID puuid, BigDecimal damage, BigDecimal money) { // this.puuid = puuid; // this.damage = damage; // this.calculatedMoney = money; // } // // public UUID getPlayerUUID() { // return puuid; // } // // public BigDecimal getDamage() { // return damage; // } // // public void increaseDamage(BigDecimal damage) { // this.damage = this.damage.add(damage); // } // // public BigDecimal getCalculatedMoney() { // return calculatedMoney; // } // // public void setCalculatedMoney(BigDecimal calculatedMoney) { // this.calculatedMoney = calculatedMoney; // } // }
import net.diecode.killermoney.objects.CashTransferProperties; import net.diecode.killermoney.objects.EntityDamage; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.util.ArrayList;
package net.diecode.killermoney.events; public class KMCashTransferProcessorEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList();
// Path: src/net/diecode/killermoney/objects/CashTransferProperties.java // public class CashTransferProperties { // // private double percent; // private int maxAmount; // private double chance; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public CashTransferProperties(double percent, int maxAmount, double chance, String permission, int limit, // DivisionMethod divisionMethod, boolean enabled) { // this.percent = percent; // this.maxAmount = maxAmount; // this.chance = chance; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public double getPercent() { // return percent; // } // // public int getMaxAmount() { // return maxAmount; // } // // public double getChance() { // return chance; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean isEnabled() { // return enabled; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.doubleValue() >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // } // // Path: src/net/diecode/killermoney/objects/EntityDamage.java // public class EntityDamage { // // private UUID puuid; // private BigDecimal damage; // private BigDecimal calculatedMoney; // // public EntityDamage(UUID puuid, BigDecimal damage) { // this.puuid = puuid; // this.damage = damage; // } // // public EntityDamage(UUID puuid, BigDecimal damage, BigDecimal money) { // this.puuid = puuid; // this.damage = damage; // this.calculatedMoney = money; // } // // public UUID getPlayerUUID() { // return puuid; // } // // public BigDecimal getDamage() { // return damage; // } // // public void increaseDamage(BigDecimal damage) { // this.damage = this.damage.add(damage); // } // // public BigDecimal getCalculatedMoney() { // return calculatedMoney; // } // // public void setCalculatedMoney(BigDecimal calculatedMoney) { // this.calculatedMoney = calculatedMoney; // } // } // Path: src/net/diecode/killermoney/events/KMCashTransferProcessorEvent.java import net.diecode.killermoney.objects.CashTransferProperties; import net.diecode.killermoney.objects.EntityDamage; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.util.ArrayList; package net.diecode.killermoney.events; public class KMCashTransferProcessorEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList();
private CashTransferProperties cashTransferProperties;
diecode/KillerMoney
src/net/diecode/killermoney/events/KMCashTransferProcessorEvent.java
// Path: src/net/diecode/killermoney/objects/CashTransferProperties.java // public class CashTransferProperties { // // private double percent; // private int maxAmount; // private double chance; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public CashTransferProperties(double percent, int maxAmount, double chance, String permission, int limit, // DivisionMethod divisionMethod, boolean enabled) { // this.percent = percent; // this.maxAmount = maxAmount; // this.chance = chance; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public double getPercent() { // return percent; // } // // public int getMaxAmount() { // return maxAmount; // } // // public double getChance() { // return chance; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean isEnabled() { // return enabled; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.doubleValue() >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // } // // Path: src/net/diecode/killermoney/objects/EntityDamage.java // public class EntityDamage { // // private UUID puuid; // private BigDecimal damage; // private BigDecimal calculatedMoney; // // public EntityDamage(UUID puuid, BigDecimal damage) { // this.puuid = puuid; // this.damage = damage; // } // // public EntityDamage(UUID puuid, BigDecimal damage, BigDecimal money) { // this.puuid = puuid; // this.damage = damage; // this.calculatedMoney = money; // } // // public UUID getPlayerUUID() { // return puuid; // } // // public BigDecimal getDamage() { // return damage; // } // // public void increaseDamage(BigDecimal damage) { // this.damage = this.damage.add(damage); // } // // public BigDecimal getCalculatedMoney() { // return calculatedMoney; // } // // public void setCalculatedMoney(BigDecimal calculatedMoney) { // this.calculatedMoney = calculatedMoney; // } // }
import net.diecode.killermoney.objects.CashTransferProperties; import net.diecode.killermoney.objects.EntityDamage; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.util.ArrayList;
package net.diecode.killermoney.events; public class KMCashTransferProcessorEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private CashTransferProperties cashTransferProperties;
// Path: src/net/diecode/killermoney/objects/CashTransferProperties.java // public class CashTransferProperties { // // private double percent; // private int maxAmount; // private double chance; // private String permission; // private int limit; // private DivisionMethod divisionMethod; // private boolean enabled; // private HashMap<UUID, BigDecimal> limitCounter = new HashMap<UUID, BigDecimal>(); // // public CashTransferProperties(double percent, int maxAmount, double chance, String permission, int limit, // DivisionMethod divisionMethod, boolean enabled) { // this.percent = percent; // this.maxAmount = maxAmount; // this.chance = chance; // this.permission = permission; // this.limit = limit; // this.divisionMethod = divisionMethod; // this.enabled = enabled; // } // // public double getPercent() { // return percent; // } // // public int getMaxAmount() { // return maxAmount; // } // // public double getChance() { // return chance; // } // // public String getPermission() { // return permission; // } // // public int getLimit() { // return limit; // } // // public DivisionMethod getDivisionMethod() { // return divisionMethod; // } // // public HashMap<UUID, BigDecimal> getLimitCounter() { // return limitCounter; // } // // public boolean isEnabled() { // return enabled; // } // // public boolean chanceGen() { // return Utils.chanceGenerator(this.chance); // } // // public boolean isReachedLimit(UUID uuid) { // if (limit < 1) { // return false; // } // // Player player = Bukkit.getPlayer(uuid); // // if (player.hasPermission(KMPermission.BYPASS_MONEY_LIMIT.get())) { // return false; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal current = limitCounter.get(uuid); // // if (current.doubleValue() >= limit) { // return true; // } // } // // return false; // } // // public void increaseLimitCounter(UUID uuid, BigDecimal money) { // if (limit == 0) { // return; // } // // if (limitCounter.containsKey(uuid)) { // BigDecimal incremented = limitCounter.get(uuid).add(money); // // limitCounter.put(uuid, incremented); // } else { // limitCounter.put(uuid, money); // } // } // // public BigDecimal getCurrentLimitValue(UUID uuid) { // if (limitCounter.containsKey(uuid)) { // return limitCounter.get(uuid); // } // // return BigDecimal.ZERO; // } // } // // Path: src/net/diecode/killermoney/objects/EntityDamage.java // public class EntityDamage { // // private UUID puuid; // private BigDecimal damage; // private BigDecimal calculatedMoney; // // public EntityDamage(UUID puuid, BigDecimal damage) { // this.puuid = puuid; // this.damage = damage; // } // // public EntityDamage(UUID puuid, BigDecimal damage, BigDecimal money) { // this.puuid = puuid; // this.damage = damage; // this.calculatedMoney = money; // } // // public UUID getPlayerUUID() { // return puuid; // } // // public BigDecimal getDamage() { // return damage; // } // // public void increaseDamage(BigDecimal damage) { // this.damage = this.damage.add(damage); // } // // public BigDecimal getCalculatedMoney() { // return calculatedMoney; // } // // public void setCalculatedMoney(BigDecimal calculatedMoney) { // this.calculatedMoney = calculatedMoney; // } // } // Path: src/net/diecode/killermoney/events/KMCashTransferProcessorEvent.java import net.diecode.killermoney.objects.CashTransferProperties; import net.diecode.killermoney.objects.EntityDamage; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import java.util.ArrayList; package net.diecode.killermoney.events; public class KMCashTransferProcessorEvent extends Event implements Cancellable { private static final HandlerList handlers = new HandlerList(); private CashTransferProperties cashTransferProperties;
private ArrayList<EntityDamage> damagers;
bintray/bintray-client-java
api/src/main/java/com/jfrog/bintray/client/api/details/PackageDetails.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // }
import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.*; import org.codehaus.jackson.map.ObjectMapper; import org.joda.time.DateTime; import java.util.HashMap; import java.util.List; import java.util.Map;
private Integer ratingCount; @JsonIgnore private List<String> systemIds; @JsonProperty(value = "vcs_url") private String vcsUrl; @JsonIgnore private List<Attribute> attributes; //All other props that don't have specific fields private Map<String, Object> other = new HashMap<>(); @JsonAnySetter public void set(String name, Object value) { other.put(name, value); } @JsonAnyGetter public Map<String, Object> other() { return other; } @JsonCreator public PackageDetails() { } public PackageDetails(String name) { this.name = name; } public static ObjectMapper getObjectMapper() {
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // } // Path: api/src/main/java/com/jfrog/bintray/client/api/details/PackageDetails.java import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.*; import org.codehaus.jackson.map.ObjectMapper; import org.joda.time.DateTime; import java.util.HashMap; import java.util.List; import java.util.Map; private Integer ratingCount; @JsonIgnore private List<String> systemIds; @JsonProperty(value = "vcs_url") private String vcsUrl; @JsonIgnore private List<Attribute> attributes; //All other props that don't have specific fields private Map<String, Object> other = new HashMap<>(); @JsonAnySetter public void set(String name, Object value) { other.put(name, value); } @JsonAnyGetter public Map<String, Object> other() { return other; } @JsonCreator public PackageDetails() { } public PackageDetails(String name) { this.name = name; } public static ObjectMapper getObjectMapper() {
return ObjectMapperHelper.get();
bintray/bintray-client-java
api/src/main/java/com/jfrog/bintray/client/api/handle/Bintray.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/BintrayCallException.java // public class BintrayCallException extends HttpResponseException { // // private int statusCode; // private String reason; // private String message; // // public BintrayCallException(int statusCode, String reason, String message) { // super(statusCode, reason); // this.statusCode = statusCode; // this.reason = reason; // this.message = message; // } // // public BintrayCallException(HttpResponse response) { // super(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase()); // String message = " "; // String entity = null; // int statusCode = response.getStatusLine().getStatusCode(); // if (response.getEntity() != null && statusCode != 405 && statusCode != 500) { // try { // entity = IOUtils.toString(response.getEntity().getContent()); // ObjectMapper mapper = ObjectMapperHelper.get(); // JsonNode node = mapper.readTree(entity); // message = node.get("message").getTextValue(); // } catch (IOException | NullPointerException e) { // //Null entity? // if (entity != null) { // message = entity; // } // } // } // this.statusCode = statusCode; // this.reason = response.getStatusLine().getReasonPhrase(); // this.message = message; // } // // public BintrayCallException(Exception e) { // super(HttpStatus.SC_BAD_REQUEST, e.getMessage()); // this.statusCode = HttpStatus.SC_BAD_REQUEST; // this.reason = e.getMessage(); // this.message = (e.getCause() == null) ? " " : " : " + e.getCause().getMessage(); // } // // public int getStatusCode() { // return statusCode; // } // // public String getReason() { // return reason; // } // // @Override // public String getMessage() { // return message; // } // // public void setMessage(String newMessage) { // this.message = newMessage; // } // // @Override // public String toString() { // return statusCode + ", " + reason + " " + message; // } // // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/MultipleBintrayCallException.java // public class MultipleBintrayCallException extends Exception { // // List<BintrayCallException> exceptions; // // public MultipleBintrayCallException() { // super(); // exceptions = new ArrayList<>(); // } // // public MultipleBintrayCallException(List<BintrayCallException> exceptions) { // super(); // this.exceptions = exceptions; // } // // public List<BintrayCallException> getExceptions() { // return exceptions; // } // // // }
import com.jfrog.bintray.client.api.BintrayCallException; import com.jfrog.bintray.client.api.MultipleBintrayCallException; import org.apache.http.HttpResponse; import java.io.Closeable; import java.io.InputStream; import java.util.Map;
package com.jfrog.bintray.client.api.handle; /** * @author Noam Y. Tenne */ public interface Bintray extends Closeable { SubjectHandle subject(String subject); RepositoryHandle repository(String repositoryPath); PackageHandle pkg(String packagePath); VersionHandle version(String versionPath); /** * Following are generic HTTP requests you can perform against Bintray's API, as defined in your created client * (so the uri parameter should be the required path after api.bintray.com). * You can also optionally add your own headers to the requests. */
// Path: api/src/main/java/com/jfrog/bintray/client/api/BintrayCallException.java // public class BintrayCallException extends HttpResponseException { // // private int statusCode; // private String reason; // private String message; // // public BintrayCallException(int statusCode, String reason, String message) { // super(statusCode, reason); // this.statusCode = statusCode; // this.reason = reason; // this.message = message; // } // // public BintrayCallException(HttpResponse response) { // super(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase()); // String message = " "; // String entity = null; // int statusCode = response.getStatusLine().getStatusCode(); // if (response.getEntity() != null && statusCode != 405 && statusCode != 500) { // try { // entity = IOUtils.toString(response.getEntity().getContent()); // ObjectMapper mapper = ObjectMapperHelper.get(); // JsonNode node = mapper.readTree(entity); // message = node.get("message").getTextValue(); // } catch (IOException | NullPointerException e) { // //Null entity? // if (entity != null) { // message = entity; // } // } // } // this.statusCode = statusCode; // this.reason = response.getStatusLine().getReasonPhrase(); // this.message = message; // } // // public BintrayCallException(Exception e) { // super(HttpStatus.SC_BAD_REQUEST, e.getMessage()); // this.statusCode = HttpStatus.SC_BAD_REQUEST; // this.reason = e.getMessage(); // this.message = (e.getCause() == null) ? " " : " : " + e.getCause().getMessage(); // } // // public int getStatusCode() { // return statusCode; // } // // public String getReason() { // return reason; // } // // @Override // public String getMessage() { // return message; // } // // public void setMessage(String newMessage) { // this.message = newMessage; // } // // @Override // public String toString() { // return statusCode + ", " + reason + " " + message; // } // // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/MultipleBintrayCallException.java // public class MultipleBintrayCallException extends Exception { // // List<BintrayCallException> exceptions; // // public MultipleBintrayCallException() { // super(); // exceptions = new ArrayList<>(); // } // // public MultipleBintrayCallException(List<BintrayCallException> exceptions) { // super(); // this.exceptions = exceptions; // } // // public List<BintrayCallException> getExceptions() { // return exceptions; // } // // // } // Path: api/src/main/java/com/jfrog/bintray/client/api/handle/Bintray.java import com.jfrog.bintray.client.api.BintrayCallException; import com.jfrog.bintray.client.api.MultipleBintrayCallException; import org.apache.http.HttpResponse; import java.io.Closeable; import java.io.InputStream; import java.util.Map; package com.jfrog.bintray.client.api.handle; /** * @author Noam Y. Tenne */ public interface Bintray extends Closeable { SubjectHandle subject(String subject); RepositoryHandle repository(String repositoryPath); PackageHandle pkg(String packagePath); VersionHandle version(String versionPath); /** * Following are generic HTTP requests you can perform against Bintray's API, as defined in your created client * (so the uri parameter should be the required path after api.bintray.com). * You can also optionally add your own headers to the requests. */
HttpResponse get(String uri, Map<String, String> headers) throws BintrayCallException;
bintray/bintray-client-java
api/src/main/java/com/jfrog/bintray/client/api/handle/Bintray.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/BintrayCallException.java // public class BintrayCallException extends HttpResponseException { // // private int statusCode; // private String reason; // private String message; // // public BintrayCallException(int statusCode, String reason, String message) { // super(statusCode, reason); // this.statusCode = statusCode; // this.reason = reason; // this.message = message; // } // // public BintrayCallException(HttpResponse response) { // super(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase()); // String message = " "; // String entity = null; // int statusCode = response.getStatusLine().getStatusCode(); // if (response.getEntity() != null && statusCode != 405 && statusCode != 500) { // try { // entity = IOUtils.toString(response.getEntity().getContent()); // ObjectMapper mapper = ObjectMapperHelper.get(); // JsonNode node = mapper.readTree(entity); // message = node.get("message").getTextValue(); // } catch (IOException | NullPointerException e) { // //Null entity? // if (entity != null) { // message = entity; // } // } // } // this.statusCode = statusCode; // this.reason = response.getStatusLine().getReasonPhrase(); // this.message = message; // } // // public BintrayCallException(Exception e) { // super(HttpStatus.SC_BAD_REQUEST, e.getMessage()); // this.statusCode = HttpStatus.SC_BAD_REQUEST; // this.reason = e.getMessage(); // this.message = (e.getCause() == null) ? " " : " : " + e.getCause().getMessage(); // } // // public int getStatusCode() { // return statusCode; // } // // public String getReason() { // return reason; // } // // @Override // public String getMessage() { // return message; // } // // public void setMessage(String newMessage) { // this.message = newMessage; // } // // @Override // public String toString() { // return statusCode + ", " + reason + " " + message; // } // // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/MultipleBintrayCallException.java // public class MultipleBintrayCallException extends Exception { // // List<BintrayCallException> exceptions; // // public MultipleBintrayCallException() { // super(); // exceptions = new ArrayList<>(); // } // // public MultipleBintrayCallException(List<BintrayCallException> exceptions) { // super(); // this.exceptions = exceptions; // } // // public List<BintrayCallException> getExceptions() { // return exceptions; // } // // // }
import com.jfrog.bintray.client.api.BintrayCallException; import com.jfrog.bintray.client.api.MultipleBintrayCallException; import org.apache.http.HttpResponse; import java.io.Closeable; import java.io.InputStream; import java.util.Map;
package com.jfrog.bintray.client.api.handle; /** * @author Noam Y. Tenne */ public interface Bintray extends Closeable { SubjectHandle subject(String subject); RepositoryHandle repository(String repositoryPath); PackageHandle pkg(String packagePath); VersionHandle version(String versionPath); /** * Following are generic HTTP requests you can perform against Bintray's API, as defined in your created client * (so the uri parameter should be the required path after api.bintray.com). * You can also optionally add your own headers to the requests. */ HttpResponse get(String uri, Map<String, String> headers) throws BintrayCallException; HttpResponse head(String uri, Map<String, String> headers) throws BintrayCallException; HttpResponse post(String uri, Map<String, String> headers, InputStream elementInputStream) throws BintrayCallException; HttpResponse patch(String uri, Map<String, String> headers, InputStream elementInputStream) throws BintrayCallException; HttpResponse delete(String uri, Map<String, String> headers) throws BintrayCallException; /** * PUT single item */ HttpResponse put(String uri, Map<String, String> headers, InputStream elementInputStream) throws BintrayCallException; /** * Concurrently executes a list of {@link org.apache.http.client.methods.HttpPut} requests, which are not handled by * the default response handler to avoid any BintrayCallExceptions being thrown before all requests have executed. * * @return A list of all errors thrown while performing the requests or empty list if all requests finished OK */
// Path: api/src/main/java/com/jfrog/bintray/client/api/BintrayCallException.java // public class BintrayCallException extends HttpResponseException { // // private int statusCode; // private String reason; // private String message; // // public BintrayCallException(int statusCode, String reason, String message) { // super(statusCode, reason); // this.statusCode = statusCode; // this.reason = reason; // this.message = message; // } // // public BintrayCallException(HttpResponse response) { // super(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase()); // String message = " "; // String entity = null; // int statusCode = response.getStatusLine().getStatusCode(); // if (response.getEntity() != null && statusCode != 405 && statusCode != 500) { // try { // entity = IOUtils.toString(response.getEntity().getContent()); // ObjectMapper mapper = ObjectMapperHelper.get(); // JsonNode node = mapper.readTree(entity); // message = node.get("message").getTextValue(); // } catch (IOException | NullPointerException e) { // //Null entity? // if (entity != null) { // message = entity; // } // } // } // this.statusCode = statusCode; // this.reason = response.getStatusLine().getReasonPhrase(); // this.message = message; // } // // public BintrayCallException(Exception e) { // super(HttpStatus.SC_BAD_REQUEST, e.getMessage()); // this.statusCode = HttpStatus.SC_BAD_REQUEST; // this.reason = e.getMessage(); // this.message = (e.getCause() == null) ? " " : " : " + e.getCause().getMessage(); // } // // public int getStatusCode() { // return statusCode; // } // // public String getReason() { // return reason; // } // // @Override // public String getMessage() { // return message; // } // // public void setMessage(String newMessage) { // this.message = newMessage; // } // // @Override // public String toString() { // return statusCode + ", " + reason + " " + message; // } // // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/MultipleBintrayCallException.java // public class MultipleBintrayCallException extends Exception { // // List<BintrayCallException> exceptions; // // public MultipleBintrayCallException() { // super(); // exceptions = new ArrayList<>(); // } // // public MultipleBintrayCallException(List<BintrayCallException> exceptions) { // super(); // this.exceptions = exceptions; // } // // public List<BintrayCallException> getExceptions() { // return exceptions; // } // // // } // Path: api/src/main/java/com/jfrog/bintray/client/api/handle/Bintray.java import com.jfrog.bintray.client.api.BintrayCallException; import com.jfrog.bintray.client.api.MultipleBintrayCallException; import org.apache.http.HttpResponse; import java.io.Closeable; import java.io.InputStream; import java.util.Map; package com.jfrog.bintray.client.api.handle; /** * @author Noam Y. Tenne */ public interface Bintray extends Closeable { SubjectHandle subject(String subject); RepositoryHandle repository(String repositoryPath); PackageHandle pkg(String packagePath); VersionHandle version(String versionPath); /** * Following are generic HTTP requests you can perform against Bintray's API, as defined in your created client * (so the uri parameter should be the required path after api.bintray.com). * You can also optionally add your own headers to the requests. */ HttpResponse get(String uri, Map<String, String> headers) throws BintrayCallException; HttpResponse head(String uri, Map<String, String> headers) throws BintrayCallException; HttpResponse post(String uri, Map<String, String> headers, InputStream elementInputStream) throws BintrayCallException; HttpResponse patch(String uri, Map<String, String> headers, InputStream elementInputStream) throws BintrayCallException; HttpResponse delete(String uri, Map<String, String> headers) throws BintrayCallException; /** * PUT single item */ HttpResponse put(String uri, Map<String, String> headers, InputStream elementInputStream) throws BintrayCallException; /** * Concurrently executes a list of {@link org.apache.http.client.methods.HttpPut} requests, which are not handled by * the default response handler to avoid any BintrayCallExceptions being thrown before all requests have executed. * * @return A list of all errors thrown while performing the requests or empty list if all requests finished OK */
HttpResponse put(Map<String, InputStream> uriAndStreamMap, Map<String, String> headers) throws MultipleBintrayCallException;
bintray/bintray-client-java
api/src/main/java/com/jfrog/bintray/client/api/details/VersionDetails.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // }
import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.*; import org.codehaus.jackson.map.ObjectMapper; import org.joda.time.DateTime; import java.util.HashMap; import java.util.List; import java.util.Map;
boolean gpgSign; @JsonProperty(value = "github_release_notes_file") private String releaseNotesFile; @JsonProperty(value = "github_use_tag_release_notes") private Boolean useTagReleaseNotes; @JsonProperty("vcs_tag") private String vcsTag; //All other props that don't have specific fields private Map<String, Object> other = new HashMap<>(); @JsonAnySetter public void set(String name, Object value) { other.put(name, value); } @JsonAnyGetter public Map<String, Object> other() { return other; } public VersionDetails() { } public VersionDetails(String name) { this.name = name; } public static ObjectMapper getObjectMapper() {
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // } // Path: api/src/main/java/com/jfrog/bintray/client/api/details/VersionDetails.java import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.*; import org.codehaus.jackson.map.ObjectMapper; import org.joda.time.DateTime; import java.util.HashMap; import java.util.List; import java.util.Map; boolean gpgSign; @JsonProperty(value = "github_release_notes_file") private String releaseNotesFile; @JsonProperty(value = "github_use_tag_release_notes") private Boolean useTagReleaseNotes; @JsonProperty("vcs_tag") private String vcsTag; //All other props that don't have specific fields private Map<String, Object> other = new HashMap<>(); @JsonAnySetter public void set(String name, Object value) { other.put(name, value); } @JsonAnyGetter public Map<String, Object> other() { return other; } public VersionDetails() { } public VersionDetails(String name) { this.name = name; } public static ObjectMapper getObjectMapper() {
return ObjectMapperHelper.get();
bintray/bintray-client-java
api/src/main/java/com/jfrog/bintray/client/api/details/SubjectDetails.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // }
import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.JsonAnyGetter; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.map.ObjectMapper; import org.joda.time.DateTime; import java.util.HashMap; import java.util.List; import java.util.Map;
package com.jfrog.bintray.client.api.details; /** * This class is used to serialize and deserialize the needed json to * pass to or receive from Bintray when performing actions on a subject * NOTE: when serializing this class use getObjectMapper to obtain a suitable mapper for this class * * @author Dan Feldman */ @JsonIgnoreProperties(ignoreUnknown = true) public class SubjectDetails { @JsonProperty("name") String name; @JsonProperty("full_name") String fullName; @JsonProperty("gravatar_id") String gravatarId; @JsonProperty("repos") List<String> repos; @JsonProperty("organizations") List<String> organizations; @JsonProperty("followers_count") Integer followersCount; @JsonProperty("registered") DateTime registered; @JsonProperty("quota_used_bytes") Long quotaUsedBytes; //All other props that don't have specific fields private Map<String, Object> other = new HashMap<>(); @JsonAnySetter public void set(String name, Object value) { other.put(name, value); } @JsonAnyGetter public Map<String, Object> other() { return other; } public static ObjectMapper getObjectMapper() {
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // } // Path: api/src/main/java/com/jfrog/bintray/client/api/details/SubjectDetails.java import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.JsonAnyGetter; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonProperty; import org.codehaus.jackson.map.ObjectMapper; import org.joda.time.DateTime; import java.util.HashMap; import java.util.List; import java.util.Map; package com.jfrog.bintray.client.api.details; /** * This class is used to serialize and deserialize the needed json to * pass to or receive from Bintray when performing actions on a subject * NOTE: when serializing this class use getObjectMapper to obtain a suitable mapper for this class * * @author Dan Feldman */ @JsonIgnoreProperties(ignoreUnknown = true) public class SubjectDetails { @JsonProperty("name") String name; @JsonProperty("full_name") String fullName; @JsonProperty("gravatar_id") String gravatarId; @JsonProperty("repos") List<String> repos; @JsonProperty("organizations") List<String> organizations; @JsonProperty("followers_count") Integer followersCount; @JsonProperty("registered") DateTime registered; @JsonProperty("quota_used_bytes") Long quotaUsedBytes; //All other props that don't have specific fields private Map<String, Object> other = new HashMap<>(); @JsonAnySetter public void set(String name, Object value) { other.put(name, value); } @JsonAnyGetter public Map<String, Object> other() { return other; } public static ObjectMapper getObjectMapper() {
return ObjectMapperHelper.get();
bintray/bintray-client-java
impl/src/main/java/com/jfrog/bintray/client/impl/model/SubjectImpl.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/details/SubjectDetails.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class SubjectDetails { // // @JsonProperty("name") // String name; // @JsonProperty("full_name") // String fullName; // @JsonProperty("gravatar_id") // String gravatarId; // @JsonProperty("repos") // List<String> repos; // @JsonProperty("organizations") // List<String> organizations; // @JsonProperty("followers_count") // Integer followersCount; // @JsonProperty("registered") // DateTime registered; // @JsonProperty("quota_used_bytes") // Long quotaUsedBytes; // // //All other props that don't have specific fields // private Map<String, Object> other = new HashMap<>(); // // @JsonAnySetter // public void set(String name, Object value) { // other.put(name, value); // } // // @JsonAnyGetter // public Map<String, Object> other() { // return other; // } // // public static ObjectMapper getObjectMapper() { // return ObjectMapperHelper.get(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getFullName() { // return fullName; // } // // public void setFullName(String fullName) { // this.fullName = fullName; // } // // public String getGravatarId() { // return gravatarId; // } // // public void setGravatarId(String gravatarId) { // this.gravatarId = gravatarId; // } // // public List<String> getRepos() { // return repos; // } // // public void setRepos(List<String> repos) { // this.repos = repos; // } // // public List<String> getOrganizations() { // return organizations; // } // // public void setOrganizations(List<String> organizations) { // this.organizations = organizations; // } // // public Integer getFollowersCount() { // return followersCount; // } // // public void setFollowersCount(Integer followersCount) { // this.followersCount = followersCount; // } // // public DateTime getRegistered() { // return registered; // } // // public void setRegistered(DateTime registered) { // this.registered = registered; // } // // public Long getQuotaUsedBytes() { // return quotaUsedBytes; // } // // public void setQuotaUsedBytes(Long quotaUsedBytes) { // this.quotaUsedBytes = quotaUsedBytes; // } // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/model/Subject.java // public interface Subject { // // String getName(); // // String getFullName(); // // String getGravatarId(); // // Collection<String> getRepositories(); // // Collection<String> getOrganizations(); // // Integer getFollowersCount(); // // DateTime getRegistered(); // // Long getQuotaUsedBytes(); // // Object getFieldByKey(String key); // }
import com.jfrog.bintray.client.api.details.SubjectDetails; import com.jfrog.bintray.client.api.model.Subject; import org.joda.time.DateTime; import java.util.Collection; import java.util.Map;
package com.jfrog.bintray.client.impl.model; /** * @author Noam Y. Tenne */ public class SubjectImpl implements Subject { private String name; private String fullName; private String gravatarId; private Collection<String> repositories; private Collection<String> organizations; private Integer followersCount; private DateTime registered; private Long quotaUsedBytes; private Map<String, Object> other; public SubjectImpl() { }
// Path: api/src/main/java/com/jfrog/bintray/client/api/details/SubjectDetails.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class SubjectDetails { // // @JsonProperty("name") // String name; // @JsonProperty("full_name") // String fullName; // @JsonProperty("gravatar_id") // String gravatarId; // @JsonProperty("repos") // List<String> repos; // @JsonProperty("organizations") // List<String> organizations; // @JsonProperty("followers_count") // Integer followersCount; // @JsonProperty("registered") // DateTime registered; // @JsonProperty("quota_used_bytes") // Long quotaUsedBytes; // // //All other props that don't have specific fields // private Map<String, Object> other = new HashMap<>(); // // @JsonAnySetter // public void set(String name, Object value) { // other.put(name, value); // } // // @JsonAnyGetter // public Map<String, Object> other() { // return other; // } // // public static ObjectMapper getObjectMapper() { // return ObjectMapperHelper.get(); // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getFullName() { // return fullName; // } // // public void setFullName(String fullName) { // this.fullName = fullName; // } // // public String getGravatarId() { // return gravatarId; // } // // public void setGravatarId(String gravatarId) { // this.gravatarId = gravatarId; // } // // public List<String> getRepos() { // return repos; // } // // public void setRepos(List<String> repos) { // this.repos = repos; // } // // public List<String> getOrganizations() { // return organizations; // } // // public void setOrganizations(List<String> organizations) { // this.organizations = organizations; // } // // public Integer getFollowersCount() { // return followersCount; // } // // public void setFollowersCount(Integer followersCount) { // this.followersCount = followersCount; // } // // public DateTime getRegistered() { // return registered; // } // // public void setRegistered(DateTime registered) { // this.registered = registered; // } // // public Long getQuotaUsedBytes() { // return quotaUsedBytes; // } // // public void setQuotaUsedBytes(Long quotaUsedBytes) { // this.quotaUsedBytes = quotaUsedBytes; // } // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/model/Subject.java // public interface Subject { // // String getName(); // // String getFullName(); // // String getGravatarId(); // // Collection<String> getRepositories(); // // Collection<String> getOrganizations(); // // Integer getFollowersCount(); // // DateTime getRegistered(); // // Long getQuotaUsedBytes(); // // Object getFieldByKey(String key); // } // Path: impl/src/main/java/com/jfrog/bintray/client/impl/model/SubjectImpl.java import com.jfrog.bintray.client.api.details.SubjectDetails; import com.jfrog.bintray.client.api.model.Subject; import org.joda.time.DateTime; import java.util.Collection; import java.util.Map; package com.jfrog.bintray.client.impl.model; /** * @author Noam Y. Tenne */ public class SubjectImpl implements Subject { private String name; private String fullName; private String gravatarId; private Collection<String> repositories; private Collection<String> organizations; private Integer followersCount; private DateTime registered; private Long quotaUsedBytes; private Map<String, Object> other; public SubjectImpl() { }
public SubjectImpl(SubjectDetails subjectDetails) {
bintray/bintray-client-java
impl/src/main/java/com/jfrog/bintray/client/impl/model/ProductImpl.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/details/ProductDetails.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ProductDetails { // // //Properties marked with @JsonPropery here are serialized to the create \ update version requests, the rest are // // only deserialized when getting the version info // @JsonProperty // String name; // @JsonIgnore // String owner; // @JsonProperty(value = "desc") // String description; // @JsonIgnore // DateTime created; // @JsonProperty(value = "website_url") // String websiteUrl; // @JsonProperty(value = "vcs_url") // String vcsUrl; // @JsonProperty // List<String> packages; // @JsonIgnore // List<String> versions; // @JsonProperty(value = "sign_url_expiry") // Integer signUrlExpiry; // // //All other props that don't have specific fields // private Map<String, Object> other = new HashMap<>(); // // @JsonAnySetter // public void set(String name, Object value) { // other.put(name, value); // } // // @JsonAnyGetter // public Map<String, Object> other() { // return other; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getOwner() { // return owner; // } // // public void setOwner(String owner) { // this.owner = owner; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @JsonIgnore // public DateTime getCreated() { // return created; // } // // @JsonProperty(value = "created") // public void setCreated(DateTime created) { // this.created = created; // } // // public String getWebsiteUrl() { // return websiteUrl; // } // // public void setWebsiteUrl(String websiteUrl) { // this.websiteUrl = websiteUrl; // } // // public String getVcsUrl() { // return vcsUrl; // } // // public void setVcsUrl(String vcsUrl) { // this.vcsUrl = vcsUrl; // } // // public List<String> getPackages() { // return packages; // } // // public void setPackages(List<String> packages) { // this.packages = packages; // } // // @JsonIgnore // public List<String> getVersions() { // return versions; // } // // @JsonProperty // public void setVersions(List<String> versions) { // this.versions = versions; // } // // public Integer getSignUrlExpiry() { // return signUrlExpiry; // } // // public void setSignUrlExpiry(Integer signUrlExpiry) { // this.signUrlExpiry = signUrlExpiry; // } // // public static ObjectMapper getObjectMapper() { // return ObjectMapperHelper.get(); // } // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/model/Product.java // public interface Product { // // String getName(); // // String getOwner(); // // String getDescription(); // // DateTime getCreated(); // // String getWebsiteUrl(); // // String getVcsUrl(); // // List<String> getPackages(); // // List<String> getVersions(); // // Object getFieldByKey(String key); // }
import com.jfrog.bintray.client.api.details.ProductDetails; import com.jfrog.bintray.client.api.model.Product; import org.joda.time.DateTime; import java.util.List; import java.util.Map;
package com.jfrog.bintray.client.impl.model; /** * @author Dan Feldman */ public class ProductImpl implements Product { private String name; private String owner; private String description; private DateTime created; private String websiteUrl; private String vcsUrl; private List<String> packages; private List<String> versions; private Map<String, Object> other; public ProductImpl() { }
// Path: api/src/main/java/com/jfrog/bintray/client/api/details/ProductDetails.java // @JsonIgnoreProperties(ignoreUnknown = true) // public class ProductDetails { // // //Properties marked with @JsonPropery here are serialized to the create \ update version requests, the rest are // // only deserialized when getting the version info // @JsonProperty // String name; // @JsonIgnore // String owner; // @JsonProperty(value = "desc") // String description; // @JsonIgnore // DateTime created; // @JsonProperty(value = "website_url") // String websiteUrl; // @JsonProperty(value = "vcs_url") // String vcsUrl; // @JsonProperty // List<String> packages; // @JsonIgnore // List<String> versions; // @JsonProperty(value = "sign_url_expiry") // Integer signUrlExpiry; // // //All other props that don't have specific fields // private Map<String, Object> other = new HashMap<>(); // // @JsonAnySetter // public void set(String name, Object value) { // other.put(name, value); // } // // @JsonAnyGetter // public Map<String, Object> other() { // return other; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getOwner() { // return owner; // } // // public void setOwner(String owner) { // this.owner = owner; // } // // public String getDescription() { // return description; // } // // public void setDescription(String description) { // this.description = description; // } // // @JsonIgnore // public DateTime getCreated() { // return created; // } // // @JsonProperty(value = "created") // public void setCreated(DateTime created) { // this.created = created; // } // // public String getWebsiteUrl() { // return websiteUrl; // } // // public void setWebsiteUrl(String websiteUrl) { // this.websiteUrl = websiteUrl; // } // // public String getVcsUrl() { // return vcsUrl; // } // // public void setVcsUrl(String vcsUrl) { // this.vcsUrl = vcsUrl; // } // // public List<String> getPackages() { // return packages; // } // // public void setPackages(List<String> packages) { // this.packages = packages; // } // // @JsonIgnore // public List<String> getVersions() { // return versions; // } // // @JsonProperty // public void setVersions(List<String> versions) { // this.versions = versions; // } // // public Integer getSignUrlExpiry() { // return signUrlExpiry; // } // // public void setSignUrlExpiry(Integer signUrlExpiry) { // this.signUrlExpiry = signUrlExpiry; // } // // public static ObjectMapper getObjectMapper() { // return ObjectMapperHelper.get(); // } // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/model/Product.java // public interface Product { // // String getName(); // // String getOwner(); // // String getDescription(); // // DateTime getCreated(); // // String getWebsiteUrl(); // // String getVcsUrl(); // // List<String> getPackages(); // // List<String> getVersions(); // // Object getFieldByKey(String key); // } // Path: impl/src/main/java/com/jfrog/bintray/client/impl/model/ProductImpl.java import com.jfrog.bintray.client.api.details.ProductDetails; import com.jfrog.bintray.client.api.model.Product; import org.joda.time.DateTime; import java.util.List; import java.util.Map; package com.jfrog.bintray.client.impl.model; /** * @author Dan Feldman */ public class ProductImpl implements Product { private String name; private String owner; private String description; private DateTime created; private String websiteUrl; private String vcsUrl; private List<String> packages; private List<String> versions; private Map<String, Object> other; public ProductImpl() { }
public ProductImpl(ProductDetails productDetails) {
bintray/bintray-client-java
api/src/main/java/com/jfrog/bintray/client/api/details/RepositoryDetails.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // }
import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.*; import org.codehaus.jackson.map.ObjectMapper; import org.joda.time.DateTime; import java.util.HashMap; import java.util.List; import java.util.Map;
Boolean isPrivate; @JsonProperty Boolean premium; @JsonProperty(value = "desc") String description; @JsonProperty List<String> labels; @JsonProperty Integer yum_metadata_depth; @JsonIgnore DateTime created; @JsonIgnore Integer packageCount; @JsonIgnore Boolean updateExisting; //Property is not used in the Bintray API but Artifactory uses is in it's Bintray integration //All other props that don't have specific fields private Map<String, Object> other = new HashMap<>(); @JsonAnySetter public void set(String name, Object value) { other.put(name, value); } @JsonAnyGetter public Map<String, Object> other() { return other; } public static ObjectMapper getObjectMapper() {
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // } // Path: api/src/main/java/com/jfrog/bintray/client/api/details/RepositoryDetails.java import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.*; import org.codehaus.jackson.map.ObjectMapper; import org.joda.time.DateTime; import java.util.HashMap; import java.util.List; import java.util.Map; Boolean isPrivate; @JsonProperty Boolean premium; @JsonProperty(value = "desc") String description; @JsonProperty List<String> labels; @JsonProperty Integer yum_metadata_depth; @JsonIgnore DateTime created; @JsonIgnore Integer packageCount; @JsonIgnore Boolean updateExisting; //Property is not used in the Bintray API but Artifactory uses is in it's Bintray integration //All other props that don't have specific fields private Map<String, Object> other = new HashMap<>(); @JsonAnySetter public void set(String name, Object value) { other.put(name, value); } @JsonAnyGetter public Map<String, Object> other() { return other; } public static ObjectMapper getObjectMapper() {
return ObjectMapperHelper.get();
bintray/bintray-client-java
api/src/main/java/com/jfrog/bintray/client/api/handle/AttributesSearchQueryClause.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/model/Pkg.java // public interface Pkg { // // String name(); // // String repository(); // // String owner(); // // String description(); // // List<String> labels(); // // List<String> attributeNames(); // // Integer rating(); // // Integer ratingCount(); // // Integer followersCount(); // // DateTime created(); // // List<String> versions(); // // String latestVersion(); // // DateTime updated(); // // List<String> linkedToRepos(); // // List<String> systemIds(); // // List<String> licenses(); // // String vcsUrl(); // // Object getFieldByKey(String key); // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/model/Version.java // public interface Version { // // String name(); // // String description(); // // String pkg(); // // String repository(); // // String owner(); // // List<String> labels(); // // List<String> attributeNames(); // // DateTime created(); // // DateTime updated(); // // DateTime released(); // // Integer ordinal(); // // String vcsTag(); // // Object getFieldByKey(String key); // }
import com.jfrog.bintray.client.api.model.Pkg; import com.jfrog.bintray.client.api.model.Version; import org.joda.time.DateTime; import java.io.IOException; import java.util.List;
package com.jfrog.bintray.client.api.handle; /** * @author jbaruch * @since 13/11/13 */ public interface AttributesSearchQueryClause { AttributesSearchQueryClause in(String... values); AttributesSearchQueryClause equalsVal(Object value); AttributesSearchQueryClause greaterThan(int value); AttributesSearchQueryClause greaterOrEqualsTo(int value); AttributesSearchQueryClause lessThan(int value); AttributesSearchQueryClause lessOrEquals(int value); AttributesSearchQueryClause before(DateTime value); AttributesSearchQueryClause beforeOrAt(DateTime value); AttributesSearchQueryClause at(DateTime value); AttributesSearchQueryClause after(DateTime value); AttributesSearchQueryClause afterOrAt(DateTime value); AttributesSearchQuery and();
// Path: api/src/main/java/com/jfrog/bintray/client/api/model/Pkg.java // public interface Pkg { // // String name(); // // String repository(); // // String owner(); // // String description(); // // List<String> labels(); // // List<String> attributeNames(); // // Integer rating(); // // Integer ratingCount(); // // Integer followersCount(); // // DateTime created(); // // List<String> versions(); // // String latestVersion(); // // DateTime updated(); // // List<String> linkedToRepos(); // // List<String> systemIds(); // // List<String> licenses(); // // String vcsUrl(); // // Object getFieldByKey(String key); // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/model/Version.java // public interface Version { // // String name(); // // String description(); // // String pkg(); // // String repository(); // // String owner(); // // List<String> labels(); // // List<String> attributeNames(); // // DateTime created(); // // DateTime updated(); // // DateTime released(); // // Integer ordinal(); // // String vcsTag(); // // Object getFieldByKey(String key); // } // Path: api/src/main/java/com/jfrog/bintray/client/api/handle/AttributesSearchQueryClause.java import com.jfrog.bintray.client.api.model.Pkg; import com.jfrog.bintray.client.api.model.Version; import org.joda.time.DateTime; import java.io.IOException; import java.util.List; package com.jfrog.bintray.client.api.handle; /** * @author jbaruch * @since 13/11/13 */ public interface AttributesSearchQueryClause { AttributesSearchQueryClause in(String... values); AttributesSearchQueryClause equalsVal(Object value); AttributesSearchQueryClause greaterThan(int value); AttributesSearchQueryClause greaterOrEqualsTo(int value); AttributesSearchQueryClause lessThan(int value); AttributesSearchQueryClause lessOrEquals(int value); AttributesSearchQueryClause before(DateTime value); AttributesSearchQueryClause beforeOrAt(DateTime value); AttributesSearchQueryClause at(DateTime value); AttributesSearchQueryClause after(DateTime value); AttributesSearchQueryClause afterOrAt(DateTime value); AttributesSearchQuery and();
List<Pkg> searchPackage() throws IOException;
bintray/bintray-client-java
api/src/main/java/com/jfrog/bintray/client/api/handle/AttributesSearchQueryClause.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/model/Pkg.java // public interface Pkg { // // String name(); // // String repository(); // // String owner(); // // String description(); // // List<String> labels(); // // List<String> attributeNames(); // // Integer rating(); // // Integer ratingCount(); // // Integer followersCount(); // // DateTime created(); // // List<String> versions(); // // String latestVersion(); // // DateTime updated(); // // List<String> linkedToRepos(); // // List<String> systemIds(); // // List<String> licenses(); // // String vcsUrl(); // // Object getFieldByKey(String key); // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/model/Version.java // public interface Version { // // String name(); // // String description(); // // String pkg(); // // String repository(); // // String owner(); // // List<String> labels(); // // List<String> attributeNames(); // // DateTime created(); // // DateTime updated(); // // DateTime released(); // // Integer ordinal(); // // String vcsTag(); // // Object getFieldByKey(String key); // }
import com.jfrog.bintray.client.api.model.Pkg; import com.jfrog.bintray.client.api.model.Version; import org.joda.time.DateTime; import java.io.IOException; import java.util.List;
package com.jfrog.bintray.client.api.handle; /** * @author jbaruch * @since 13/11/13 */ public interface AttributesSearchQueryClause { AttributesSearchQueryClause in(String... values); AttributesSearchQueryClause equalsVal(Object value); AttributesSearchQueryClause greaterThan(int value); AttributesSearchQueryClause greaterOrEqualsTo(int value); AttributesSearchQueryClause lessThan(int value); AttributesSearchQueryClause lessOrEquals(int value); AttributesSearchQueryClause before(DateTime value); AttributesSearchQueryClause beforeOrAt(DateTime value); AttributesSearchQueryClause at(DateTime value); AttributesSearchQueryClause after(DateTime value); AttributesSearchQueryClause afterOrAt(DateTime value); AttributesSearchQuery and(); List<Pkg> searchPackage() throws IOException;
// Path: api/src/main/java/com/jfrog/bintray/client/api/model/Pkg.java // public interface Pkg { // // String name(); // // String repository(); // // String owner(); // // String description(); // // List<String> labels(); // // List<String> attributeNames(); // // Integer rating(); // // Integer ratingCount(); // // Integer followersCount(); // // DateTime created(); // // List<String> versions(); // // String latestVersion(); // // DateTime updated(); // // List<String> linkedToRepos(); // // List<String> systemIds(); // // List<String> licenses(); // // String vcsUrl(); // // Object getFieldByKey(String key); // } // // Path: api/src/main/java/com/jfrog/bintray/client/api/model/Version.java // public interface Version { // // String name(); // // String description(); // // String pkg(); // // String repository(); // // String owner(); // // List<String> labels(); // // List<String> attributeNames(); // // DateTime created(); // // DateTime updated(); // // DateTime released(); // // Integer ordinal(); // // String vcsTag(); // // Object getFieldByKey(String key); // } // Path: api/src/main/java/com/jfrog/bintray/client/api/handle/AttributesSearchQueryClause.java import com.jfrog.bintray.client.api.model.Pkg; import com.jfrog.bintray.client.api.model.Version; import org.joda.time.DateTime; import java.io.IOException; import java.util.List; package com.jfrog.bintray.client.api.handle; /** * @author jbaruch * @since 13/11/13 */ public interface AttributesSearchQueryClause { AttributesSearchQueryClause in(String... values); AttributesSearchQueryClause equalsVal(Object value); AttributesSearchQueryClause greaterThan(int value); AttributesSearchQueryClause greaterOrEqualsTo(int value); AttributesSearchQueryClause lessThan(int value); AttributesSearchQueryClause lessOrEquals(int value); AttributesSearchQueryClause before(DateTime value); AttributesSearchQueryClause beforeOrAt(DateTime value); AttributesSearchQueryClause at(DateTime value); AttributesSearchQueryClause after(DateTime value); AttributesSearchQueryClause afterOrAt(DateTime value); AttributesSearchQuery and(); List<Pkg> searchPackage() throws IOException;
List<Version> searchVersion() throws IOException;
bintray/bintray-client-java
api/src/main/java/com/jfrog/bintray/client/api/details/ProductDetails.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // }
import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.*; import org.codehaus.jackson.map.ObjectMapper; import org.joda.time.DateTime; import java.util.HashMap; import java.util.List; import java.util.Map;
this.vcsUrl = vcsUrl; } public List<String> getPackages() { return packages; } public void setPackages(List<String> packages) { this.packages = packages; } @JsonIgnore public List<String> getVersions() { return versions; } @JsonProperty public void setVersions(List<String> versions) { this.versions = versions; } public Integer getSignUrlExpiry() { return signUrlExpiry; } public void setSignUrlExpiry(Integer signUrlExpiry) { this.signUrlExpiry = signUrlExpiry; } public static ObjectMapper getObjectMapper() {
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // } // Path: api/src/main/java/com/jfrog/bintray/client/api/details/ProductDetails.java import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.*; import org.codehaus.jackson.map.ObjectMapper; import org.joda.time.DateTime; import java.util.HashMap; import java.util.List; import java.util.Map; this.vcsUrl = vcsUrl; } public List<String> getPackages() { return packages; } public void setPackages(List<String> packages) { this.packages = packages; } @JsonIgnore public List<String> getVersions() { return versions; } @JsonProperty public void setVersions(List<String> versions) { this.versions = versions; } public Integer getSignUrlExpiry() { return signUrlExpiry; } public void setSignUrlExpiry(Integer signUrlExpiry) { this.signUrlExpiry = signUrlExpiry; } public static ObjectMapper getObjectMapper() {
return ObjectMapperHelper.get();
bintray/bintray-client-java
api/src/main/java/com/jfrog/bintray/client/api/details/Attribute.java
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // }
import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.*; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.type.TypeReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.io.InputStream; import java.util.List; import static java.util.Arrays.asList;
package com.jfrog.bintray.client.api.details; /** * This class represents an attribute (version or package) * NOTE: when serializing this class use getObjectMapper to obtain a suitable mapper for this class * * @author Dan Feldman */ @JsonPropertyOrder({"name", "values", "type"}) @JsonIgnoreProperties(ignoreUnknown = true) public class Attribute<T> { private static final Logger log = LoggerFactory.getLogger(Attribute.class); @JsonProperty("name") private String name; @JsonProperty("values") private List<T> values; @JsonProperty("type") private Type type; @SafeVarargs public Attribute(String name, T... values) { this(name, null, asList(values)); } @SafeVarargs public Attribute(String name, Type type, T... values) { this(name, type, asList(values)); } @JsonCreator public Attribute(@JsonProperty("name") String name, @JsonProperty("type") Type type, @JsonProperty("values") List<T> values) { this.name = name; if (type == null) { type = Type.string; //Type defaults to string } this.type = type; this.values = values; } public static ObjectMapper getObjectMapper() {
// Path: api/src/main/java/com/jfrog/bintray/client/api/ObjectMapperHelper.java // public class ObjectMapperHelper { // // public static ObjectMapper get() { // return buildDetailsMapper(); // } // // private static ObjectMapper buildDetailsMapper() { // ObjectMapper mapper = new ObjectMapper(new JsonFactory()); // // // TODO: when moving to Jackson 2.x these can be replaced with JodaModule // mapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false); // mapper.configure(SerializationConfig.Feature.WRITE_DATE_KEYS_AS_TIMESTAMPS, false); // // //Don't include keys with null values implicitly, only explicitly set values should be sent over // mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, false); // mapper.configure(SerializationConfig.Feature.WRITE_NULL_MAP_VALUES, false); // mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL); // return mapper; // } // } // Path: api/src/main/java/com/jfrog/bintray/client/api/details/Attribute.java import com.jfrog.bintray.client.api.ObjectMapperHelper; import org.codehaus.jackson.annotate.*; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.type.TypeReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; import java.io.InputStream; import java.util.List; import static java.util.Arrays.asList; package com.jfrog.bintray.client.api.details; /** * This class represents an attribute (version or package) * NOTE: when serializing this class use getObjectMapper to obtain a suitable mapper for this class * * @author Dan Feldman */ @JsonPropertyOrder({"name", "values", "type"}) @JsonIgnoreProperties(ignoreUnknown = true) public class Attribute<T> { private static final Logger log = LoggerFactory.getLogger(Attribute.class); @JsonProperty("name") private String name; @JsonProperty("values") private List<T> values; @JsonProperty("type") private Type type; @SafeVarargs public Attribute(String name, T... values) { this(name, null, asList(values)); } @SafeVarargs public Attribute(String name, Type type, T... values) { this(name, type, asList(values)); } @JsonCreator public Attribute(@JsonProperty("name") String name, @JsonProperty("type") Type type, @JsonProperty("values") List<T> values) { this.name = name; if (type == null) { type = Type.string; //Type defaults to string } this.type = type; this.values = values; } public static ObjectMapper getObjectMapper() {
return ObjectMapperHelper.get();
timothymdavis/taciturn
src/main/java/io/taciturn/utility/LongUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import static io.taciturn.Utility.$;
package io.taciturn.utility; public class LongUtility extends ComparableUtility<Long> { public static final long DEFAULT_VALUE = 0L; public LongUtility(Long object) { super(object); } @Override public String toString() { return map(o -> Long.toString(o)).orElse(null); } public StringUtility mapToString() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/LongUtility.java import static io.taciturn.Utility.$; package io.taciturn.utility; public class LongUtility extends ComparableUtility<Long> { public static final long DEFAULT_VALUE = 0L; public LongUtility(Long object) { super(object); } @Override public String toString() { return map(o -> Long.toString(o)).orElse(null); } public StringUtility mapToString() {
return $(toString());
timothymdavis/taciturn
src/test/java/io/taciturn/utility/StreamUtilityTest.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Set; import java.util.Vector; import org.junit.Test; import static io.taciturn.Utility.$; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertThat;
package io.taciturn.utility; public class StreamUtilityTest { @Test public void testTo() throws Exception {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/test/java/io/taciturn/utility/StreamUtilityTest.java import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Set; import java.util.Vector; import org.junit.Test; import static io.taciturn.Utility.$; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertThat; package io.taciturn.utility; public class StreamUtilityTest { @Test public void testTo() throws Exception {
assertThat($((Object) null).mapToStream().to(new ArrayList<>()).orElse(null), nullValue());
timothymdavis/taciturn
src/test/java/io/taciturn/utility/AbstractUtilityTest.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import org.junit.Test; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Optional; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertThat; import static io.taciturn.Utility.$; import static org.junit.Assert.fail;
package io.taciturn.utility; public class AbstractUtilityTest { @Test public void testIsPresent() throws Exception {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/test/java/io/taciturn/utility/AbstractUtilityTest.java import org.junit.Test; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Optional; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNot.not; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertThat; import static io.taciturn.Utility.$; import static org.junit.Assert.fail; package io.taciturn.utility; public class AbstractUtilityTest { @Test public void testIsPresent() throws Exception {
assertThat($(new Object()).isPresent(), is(true));
timothymdavis/taciturn
src/main/java/io/taciturn/utility/LocalDateTimeUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.temporal.Temporal; import java.util.Date; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class LocalDateTimeUtility extends ObjectUtility<LocalDateTime> { public LocalDateTimeUtility(LocalDateTime object) { super(object); } public Temporal asTemporal() { return map(o -> (Temporal) o).orElse(null); } public Date toDate() { return map(o -> Date.from(o.atZone(ZoneId.systemDefault()).toInstant())).orElse(null); } public Date toDate(ZoneId zoneId) { return map(o -> Date.from(o.atZone(zoneId).toInstant())).orElse(null); } public DateUtility mapToDate() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/LocalDateTimeUtility.java import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZoneOffset; import java.time.temporal.Temporal; import java.util.Date; import static io.taciturn.Utility.$; package io.taciturn.utility; public class LocalDateTimeUtility extends ObjectUtility<LocalDateTime> { public LocalDateTimeUtility(LocalDateTime object) { super(object); } public Temporal asTemporal() { return map(o -> (Temporal) o).orElse(null); } public Date toDate() { return map(o -> Date.from(o.atZone(ZoneId.systemDefault()).toInstant())).orElse(null); } public Date toDate(ZoneId zoneId) { return map(o -> Date.from(o.atZone(zoneId).toInstant())).orElse(null); } public DateUtility mapToDate() {
return $(toDate());
timothymdavis/taciturn
src/main/java/io/taciturn/utility/ObjectUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Set; import java.util.Vector; import java.util.function.Predicate; import java.util.stream.Stream; import static io.taciturn.Utility.$;
package io.taciturn.utility; /** * Utility functions that apply to all objects. * * @param <Item> The type of object to augment. */ public class ObjectUtility<Item> extends AbstractUtility<Item> { /** * Constructor for the utility object. * * @param object The object to augment. */ public ObjectUtility(Item object) { super(object); } /** * Retrieves the fields for a particular object, limited by the predicate provided. * @param filter The {@link Predicate} that limits what fields to retrieve. * @return the utility that wraps the collection of {@link FieldUtility} objects. */ public StreamUtility<FieldUtility> getFields(Predicate<Field> filter) { return map(Object::getClass) .map(Class::getDeclaredFields)
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/ObjectUtility.java import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Set; import java.util.Vector; import java.util.function.Predicate; import java.util.stream.Stream; import static io.taciturn.Utility.$; package io.taciturn.utility; /** * Utility functions that apply to all objects. * * @param <Item> The type of object to augment. */ public class ObjectUtility<Item> extends AbstractUtility<Item> { /** * Constructor for the utility object. * * @param object The object to augment. */ public ObjectUtility(Item object) { super(object); } /** * Retrieves the fields for a particular object, limited by the predicate provided. * @param filter The {@link Predicate} that limits what fields to retrieve. * @return the utility that wraps the collection of {@link FieldUtility} objects. */ public StreamUtility<FieldUtility> getFields(Predicate<Field> filter) { return map(Object::getClass) .map(Class::getDeclaredFields)
.map(o -> $(o)
timothymdavis/taciturn
src/test/java/io/taciturn/utility/ByteUtilityTest.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import org.junit.Assert; import org.junit.Test; import static io.taciturn.Utility.$; import static org.hamcrest.core.Is.is;
package io.taciturn.utility; public class ByteUtilityTest { @Test public void testToString() throws Exception {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/test/java/io/taciturn/utility/ByteUtilityTest.java import org.junit.Assert; import org.junit.Test; import static io.taciturn.Utility.$; import static org.hamcrest.core.Is.is; package io.taciturn.utility; public class ByteUtilityTest { @Test public void testToString() throws Exception {
Assert.assertThat($((byte) 1).toString(), is("1"));
timothymdavis/taciturn
src/main/java/io/taciturn/utility/FloatUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import static io.taciturn.Utility.$;
package io.taciturn.utility; public class FloatUtility extends ComparableUtility<Float> { public static final float DEFAULT_VALUE = 0.0F; public FloatUtility(Float object) { super(object); } @Override public String toString() { return map(o -> Float.toString(o)).orElse(null); } public StringUtility mapToString() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/FloatUtility.java import static io.taciturn.Utility.$; package io.taciturn.utility; public class FloatUtility extends ComparableUtility<Float> { public static final float DEFAULT_VALUE = 0.0F; public FloatUtility(Float object) { super(object); } @Override public String toString() { return map(o -> Float.toString(o)).orElse(null); } public StringUtility mapToString() {
return $(toString());
timothymdavis/taciturn
src/main/java/io/taciturn/utility/OffsetDateTimeUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.time.Instant; import java.time.LocalDateTime; import java.time.OffsetDateTime; import java.time.OffsetTime; import java.time.temporal.Temporal; import java.util.Date; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class OffsetDateTimeUtility extends ObjectUtility<OffsetDateTime> { public OffsetDateTimeUtility(OffsetDateTime object) { super(object); } public Temporal asTemporal() { return map(o -> (Temporal) o).orElse(null); } public Date toDate() { return map(o -> Date.from(o.toInstant())).orElse(null); } public DateUtility mapToDate() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/OffsetDateTimeUtility.java import java.time.Instant; import java.time.LocalDateTime; import java.time.OffsetDateTime; import java.time.OffsetTime; import java.time.temporal.Temporal; import java.util.Date; import static io.taciturn.Utility.$; package io.taciturn.utility; public class OffsetDateTimeUtility extends ObjectUtility<OffsetDateTime> { public OffsetDateTimeUtility(OffsetDateTime object) { super(object); } public Temporal asTemporal() { return map(o -> (Temporal) o).orElse(null); } public Date toDate() { return map(o -> Date.from(o.toInstant())).orElse(null); } public DateUtility mapToDate() {
return $(toDate());
timothymdavis/taciturn
src/main/java/io/taciturn/utility/IntegerUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import static io.taciturn.Utility.$;
package io.taciturn.utility; public class IntegerUtility extends ComparableUtility<Integer> { public static final int DEFAULT_VALUE = 0; public IntegerUtility(Integer object) { super(object); } @Override public String toString() { return map(o -> Integer.toString(o)).orElse(null); } public StringUtility mapToString() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/IntegerUtility.java import static io.taciturn.Utility.$; package io.taciturn.utility; public class IntegerUtility extends ComparableUtility<Integer> { public static final int DEFAULT_VALUE = 0; public IntegerUtility(Integer object) { super(object); } @Override public String toString() { return map(o -> Integer.toString(o)).orElse(null); } public StringUtility mapToString() {
return $(toString());
timothymdavis/taciturn
src/main/java/io/taciturn/utility/DateUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.time.Instant; import java.time.LocalDateTime; import java.time.OffsetDateTime; import java.time.ZoneId; import java.util.Date; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class DateUtility extends ComparableUtility<Date> { public DateUtility(Date object) { super(object); } public LocalDateTime toLocalDateTime() { return mapToInstant().map(LocalDateTime::from).orElse(null); } public LocalDateTime toLocalDateTimeWithDefaultZoneId() { return mapToInstant().map(o -> LocalDateTime.ofInstant(o, ZoneId.systemDefault())).orElse(null); } public LocalDateTime toLocalDateTime(ZoneId zoneId) { return mapToInstant().map(o -> LocalDateTime.ofInstant(o, zoneId)).orElse(null); } public LocalDateTimeUtility mapToLocalDateTimeWithDefaultZoneId() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/DateUtility.java import java.time.Instant; import java.time.LocalDateTime; import java.time.OffsetDateTime; import java.time.ZoneId; import java.util.Date; import static io.taciturn.Utility.$; package io.taciturn.utility; public class DateUtility extends ComparableUtility<Date> { public DateUtility(Date object) { super(object); } public LocalDateTime toLocalDateTime() { return mapToInstant().map(LocalDateTime::from).orElse(null); } public LocalDateTime toLocalDateTimeWithDefaultZoneId() { return mapToInstant().map(o -> LocalDateTime.ofInstant(o, ZoneId.systemDefault())).orElse(null); } public LocalDateTime toLocalDateTime(ZoneId zoneId) { return mapToInstant().map(o -> LocalDateTime.ofInstant(o, zoneId)).orElse(null); } public LocalDateTimeUtility mapToLocalDateTimeWithDefaultZoneId() {
return $(toLocalDateTimeWithDefaultZoneId());
timothymdavis/taciturn
src/main/java/io/taciturn/utility/ByteUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import static io.taciturn.Utility.$;
package io.taciturn.utility; public class ByteUtility extends ComparableUtility<Byte> { public static final byte DEFAULT_VALUE = (byte) 0; public ByteUtility(Byte object) { super(object); } @Override public String toString() { return map(o -> Byte.toString(o)).orElse(null); } public StringUtility mapToString() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/ByteUtility.java import static io.taciturn.Utility.$; package io.taciturn.utility; public class ByteUtility extends ComparableUtility<Byte> { public static final byte DEFAULT_VALUE = (byte) 0; public ByteUtility(Byte object) { super(object); } @Override public String toString() { return map(o -> Byte.toString(o)).orElse(null); } public StringUtility mapToString() {
return $(toString());
timothymdavis/taciturn
src/main/java/io/taciturn/utility/ShortUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import static io.taciturn.Utility.$;
package io.taciturn.utility; public class ShortUtility extends ComparableUtility<Short> { public static final short DEFAULT_VALUE = (short) 0; public ShortUtility(Short object) { super(object); } @Override public String toString() { return map(o -> Short.toString(o)).orElse(null); } public StringUtility mapToString() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/ShortUtility.java import static io.taciturn.Utility.$; package io.taciturn.utility; public class ShortUtility extends ComparableUtility<Short> { public static final short DEFAULT_VALUE = (short) 0; public ShortUtility(Short object) { super(object); } @Override public String toString() { return map(o -> Short.toString(o)).orElse(null); } public StringUtility mapToString() {
return $(toString());
timothymdavis/taciturn
src/main/java/io/taciturn/utility/DoubleUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import static io.taciturn.Utility.$;
package io.taciturn.utility; public class DoubleUtility extends ComparableUtility<Double> { public static final double DEFAULT_VALUE = 0.0D; public DoubleUtility(Double object) { super(object); } @Override public String toString() { return map(o -> Double.toString(o)).orElse(null); } public StringUtility mapToString() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/DoubleUtility.java import static io.taciturn.Utility.$; package io.taciturn.utility; public class DoubleUtility extends ComparableUtility<Double> { public static final double DEFAULT_VALUE = 0.0D; public DoubleUtility(Double object) { super(object); } @Override public String toString() { return map(o -> Double.toString(o)).orElse(null); } public StringUtility mapToString() {
return $(toString());
timothymdavis/taciturn
src/main/java/io/taciturn/utility/StreamUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.lang.reflect.Array; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Set; import java.util.Spliterator; import java.util.Vector; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.BinaryOperator; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import java.util.function.ToDoubleFunction; import java.util.function.ToIntFunction; import java.util.function.ToLongFunction; import java.util.stream.BaseStream; import java.util.stream.Collector; import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; import static io.taciturn.Utility.$;
package io.taciturn.utility; @SuppressWarnings("WeakerAccess") public class StreamUtility<Item> extends AbstractUtility<Stream<Item>> { public StreamUtility(Stream<Item> object) { super(object); } public boolean allMatch(Predicate<? super Item> predicate) { return map(s -> s.allMatch(predicate)).orElse(BooleanUtility.DEFAULT_VALUE); } public boolean anyMatch(Predicate<? super Item> predicate) { return map(s -> s.anyMatch(predicate)).orElse(BooleanUtility.DEFAULT_VALUE); } public void close() { ifPresent(BaseStream::close); } public <R, A> AbstractUtility<R> collect(Collector<? super Item, A, R> collector) { return map(s -> s.collect(collector)); } public <R> AbstractUtility<R> collect(Supplier<R> supplier, BiConsumer<R, ? super Item> accumulator, BiConsumer<R, R> combiner) { return map(s -> s.collect(supplier, accumulator, combiner)); } public long count() { return map(Stream::count).orElse(LongUtility.DEFAULT_VALUE); } public StreamUtility<Item> distinct() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/StreamUtility.java import java.lang.reflect.Array; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Set; import java.util.Spliterator; import java.util.Vector; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.BinaryOperator; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import java.util.function.ToDoubleFunction; import java.util.function.ToIntFunction; import java.util.function.ToLongFunction; import java.util.stream.BaseStream; import java.util.stream.Collector; import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; import static io.taciturn.Utility.$; package io.taciturn.utility; @SuppressWarnings("WeakerAccess") public class StreamUtility<Item> extends AbstractUtility<Stream<Item>> { public StreamUtility(Stream<Item> object) { super(object); } public boolean allMatch(Predicate<? super Item> predicate) { return map(s -> s.allMatch(predicate)).orElse(BooleanUtility.DEFAULT_VALUE); } public boolean anyMatch(Predicate<? super Item> predicate) { return map(s -> s.anyMatch(predicate)).orElse(BooleanUtility.DEFAULT_VALUE); } public void close() { ifPresent(BaseStream::close); } public <R, A> AbstractUtility<R> collect(Collector<? super Item, A, R> collector) { return map(s -> s.collect(collector)); } public <R> AbstractUtility<R> collect(Supplier<R> supplier, BiConsumer<R, ? super Item> accumulator, BiConsumer<R, R> combiner) { return map(s -> s.collect(supplier, accumulator, combiner)); } public long count() { return map(Stream::count).orElse(LongUtility.DEFAULT_VALUE); } public StreamUtility<Item> distinct() {
return $(map(Stream::distinct).orElse(null));
timothymdavis/taciturn
src/main/java/io/taciturn/utility/InstantUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.time.Instant; import java.time.LocalDateTime; import java.time.OffsetDateTime; import java.time.ZoneId; import java.util.Date; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class InstantUtility extends ComparableUtility<Instant> { public InstantUtility(Instant object) { super(object); } public OffsetDateTime toOffsetDateTime() { return map(OffsetDateTime::from).orElse(null); } public OffsetDateTime toOffsetDateTime(ZoneId zoneId) { return map(o -> OffsetDateTime.ofInstant(o, zoneId)).orElse(null); } public OffsetDateTime toOffsetDateTimeWithDefaultZoneId() { return map(o -> OffsetDateTime.ofInstant(o, ZoneId.systemDefault())).orElse(null); } public OffsetDateTimeUtility mapToOffsetDateTime() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/InstantUtility.java import java.time.Instant; import java.time.LocalDateTime; import java.time.OffsetDateTime; import java.time.ZoneId; import java.util.Date; import static io.taciturn.Utility.$; package io.taciturn.utility; public class InstantUtility extends ComparableUtility<Instant> { public InstantUtility(Instant object) { super(object); } public OffsetDateTime toOffsetDateTime() { return map(OffsetDateTime::from).orElse(null); } public OffsetDateTime toOffsetDateTime(ZoneId zoneId) { return map(o -> OffsetDateTime.ofInstant(o, zoneId)).orElse(null); } public OffsetDateTime toOffsetDateTimeWithDefaultZoneId() { return map(o -> OffsetDateTime.ofInstant(o, ZoneId.systemDefault())).orElse(null); } public OffsetDateTimeUtility mapToOffsetDateTime() {
return $(toOffsetDateTime());
timothymdavis/taciturn
src/main/java/io/taciturn/utility/FieldUtility.java
// Path: src/main/java/io/taciturn/function/CheckedConsumer.java // @FunctionalInterface // public interface CheckedConsumer<T> { // // void accept(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedConsumer; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$;
/** * @see Field#setLong(Object, long) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public void setLong(long primitive) { set(o -> o.setLong(parent, primitive)); } /** * @see Field#setShort(Object, short) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public void setShort(short primitive) { set(o -> o.setShort(parent, primitive)); } /** * @see Field#set(Object, Object) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public <T> void setObject(T object) { set(o -> o.set(parent, object)); }
// Path: src/main/java/io/taciturn/function/CheckedConsumer.java // @FunctionalInterface // public interface CheckedConsumer<T> { // // void accept(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/FieldUtility.java import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedConsumer; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$; /** * @see Field#setLong(Object, long) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public void setLong(long primitive) { set(o -> o.setLong(parent, primitive)); } /** * @see Field#setShort(Object, short) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public void setShort(short primitive) { set(o -> o.setShort(parent, primitive)); } /** * @see Field#set(Object, Object) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public <T> void setObject(T object) { set(o -> o.set(parent, object)); }
private void set(CheckedConsumer<Field> consumer) {
timothymdavis/taciturn
src/main/java/io/taciturn/utility/FieldUtility.java
// Path: src/main/java/io/taciturn/function/CheckedConsumer.java // @FunctionalInterface // public interface CheckedConsumer<T> { // // void accept(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedConsumer; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$;
} /** * @see Field#setShort(Object, short) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public void setShort(short primitive) { set(o -> o.setShort(parent, primitive)); } /** * @see Field#set(Object, Object) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public <T> void setObject(T object) { set(o -> o.set(parent, object)); } private void set(CheckedConsumer<Field> consumer) { wrap(o -> { consumer.accept(o); return null; }); } public void makeAccessible() {
// Path: src/main/java/io/taciturn/function/CheckedConsumer.java // @FunctionalInterface // public interface CheckedConsumer<T> { // // void accept(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/FieldUtility.java import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedConsumer; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$; } /** * @see Field#setShort(Object, short) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public void setShort(short primitive) { set(o -> o.setShort(parent, primitive)); } /** * @see Field#set(Object, Object) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public <T> void setObject(T object) { set(o -> o.set(parent, object)); } private void set(CheckedConsumer<Field> consumer) { wrap(o -> { consumer.accept(o); return null; }); } public void makeAccessible() {
ifPresent(field -> $(field).filter(f -> !Modifier.isPublic(f.getModifiers()) ||
timothymdavis/taciturn
src/main/java/io/taciturn/utility/FieldUtility.java
// Path: src/main/java/io/taciturn/function/CheckedConsumer.java // @FunctionalInterface // public interface CheckedConsumer<T> { // // void accept(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedConsumer; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$;
@SuppressWarnings("JavaDoc") public void setShort(short primitive) { set(o -> o.setShort(parent, primitive)); } /** * @see Field#set(Object, Object) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public <T> void setObject(T object) { set(o -> o.set(parent, object)); } private void set(CheckedConsumer<Field> consumer) { wrap(o -> { consumer.accept(o); return null; }); } public void makeAccessible() { ifPresent(field -> $(field).filter(f -> !Modifier.isPublic(f.getModifiers()) || Modifier.isFinal(f.getModifiers()) || !Modifier.isPublic(f.getDeclaringClass().getModifiers())) .filter(f -> !f.isAccessible()) .ifPresent(f -> f.setAccessible(true))); }
// Path: src/main/java/io/taciturn/function/CheckedConsumer.java // @FunctionalInterface // public interface CheckedConsumer<T> { // // void accept(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/FieldUtility.java import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedConsumer; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$; @SuppressWarnings("JavaDoc") public void setShort(short primitive) { set(o -> o.setShort(parent, primitive)); } /** * @see Field#set(Object, Object) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public <T> void setObject(T object) { set(o -> o.set(parent, object)); } private void set(CheckedConsumer<Field> consumer) { wrap(o -> { consumer.accept(o); return null; }); } public void makeAccessible() { ifPresent(field -> $(field).filter(f -> !Modifier.isPublic(f.getModifiers()) || Modifier.isFinal(f.getModifiers()) || !Modifier.isPublic(f.getDeclaringClass().getModifiers())) .filter(f -> !f.isAccessible()) .ifPresent(f -> f.setAccessible(true))); }
private <T> T wrap(CheckedFunction<Field, T> function) {
timothymdavis/taciturn
src/main/java/io/taciturn/utility/FieldUtility.java
// Path: src/main/java/io/taciturn/function/CheckedConsumer.java // @FunctionalInterface // public interface CheckedConsumer<T> { // // void accept(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedConsumer; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$;
set(o -> o.setShort(parent, primitive)); } /** * @see Field#set(Object, Object) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public <T> void setObject(T object) { set(o -> o.set(parent, object)); } private void set(CheckedConsumer<Field> consumer) { wrap(o -> { consumer.accept(o); return null; }); } public void makeAccessible() { ifPresent(field -> $(field).filter(f -> !Modifier.isPublic(f.getModifiers()) || Modifier.isFinal(f.getModifiers()) || !Modifier.isPublic(f.getDeclaringClass().getModifiers())) .filter(f -> !f.isAccessible()) .ifPresent(f -> f.setAccessible(true))); } private <T> T wrap(CheckedFunction<Field, T> function) { makeAccessible();
// Path: src/main/java/io/taciturn/function/CheckedConsumer.java // @FunctionalInterface // public interface CheckedConsumer<T> { // // void accept(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/FieldUtility.java import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedConsumer; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$; set(o -> o.setShort(parent, primitive)); } /** * @see Field#set(Object, Object) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException */ @SuppressWarnings("JavaDoc") public <T> void setObject(T object) { set(o -> o.set(parent, object)); } private void set(CheckedConsumer<Field> consumer) { wrap(o -> { consumer.accept(o); return null; }); } public void makeAccessible() { ifPresent(field -> $(field).filter(f -> !Modifier.isPublic(f.getModifiers()) || Modifier.isFinal(f.getModifiers()) || !Modifier.isPublic(f.getDeclaringClass().getModifiers())) .filter(f -> !f.isAccessible()) .ifPresent(f -> f.setAccessible(true))); } private <T> T wrap(CheckedFunction<Field, T> function) { makeAccessible();
return map(o -> Rethrower.rethrow(function, o)).orElse(null);
timothymdavis/taciturn
src/main/java/io/taciturn/utility/ArrayUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Set; import java.util.Spliterator; import java.util.Vector; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.BinaryOperator; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import java.util.function.ToDoubleFunction; import java.util.function.ToIntFunction; import java.util.function.ToLongFunction; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; import static io.taciturn.Utility.$;
return streamUtility.toVector(); } public CollectionUtility<Vector<Item>, Item> mapToVector() { return streamUtility.mapToVector(); } public Item[] toArray(Class<? extends Item> itemType) { return streamUtility.toArray(itemType); } public ArrayUtility<Item> mapToArray(Class<? extends Item> itemType) { return streamUtility.mapToArray(itemType); } public ArrayDeque<Item> toArrayDeque() { return streamUtility.toArrayDeque(); } public CollectionUtility<ArrayDeque<Item>, Item> mapToArrayDeque() { return streamUtility.mapToArrayDeque(); } public StreamUtility<Item> toStream() { return streamUtility; } @SuppressWarnings("unchecked") @SafeVarargs private static <Item> Item[] toArray(Item first, Item... rest) {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/ArrayUtility.java import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Set; import java.util.Spliterator; import java.util.Vector; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.BinaryOperator; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import java.util.function.ToDoubleFunction; import java.util.function.ToIntFunction; import java.util.function.ToLongFunction; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.DoubleStream; import java.util.stream.IntStream; import java.util.stream.LongStream; import java.util.stream.Stream; import static io.taciturn.Utility.$; return streamUtility.toVector(); } public CollectionUtility<Vector<Item>, Item> mapToVector() { return streamUtility.mapToVector(); } public Item[] toArray(Class<? extends Item> itemType) { return streamUtility.toArray(itemType); } public ArrayUtility<Item> mapToArray(Class<? extends Item> itemType) { return streamUtility.mapToArray(itemType); } public ArrayDeque<Item> toArrayDeque() { return streamUtility.toArrayDeque(); } public CollectionUtility<ArrayDeque<Item>, Item> mapToArrayDeque() { return streamUtility.mapToArrayDeque(); } public StreamUtility<Item> toStream() { return streamUtility; } @SuppressWarnings("unchecked") @SafeVarargs private static <Item> Item[] toArray(Item first, Item... rest) {
$(first).mustNotBeNull();
timothymdavis/taciturn
src/test/java/io/taciturn/utility/BooleanUtilityTest.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import org.junit.Assert; import org.junit.Test; import static io.taciturn.Utility.$; import static org.hamcrest.core.Is.is;
package io.taciturn.utility; public class BooleanUtilityTest { @Test public void testToString() throws Exception {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/test/java/io/taciturn/utility/BooleanUtilityTest.java import org.junit.Assert; import org.junit.Test; import static io.taciturn.Utility.$; import static org.hamcrest.core.Is.is; package io.taciturn.utility; public class BooleanUtilityTest { @Test public void testToString() throws Exception {
Assert.assertThat($(true).toString(), is("true"));
timothymdavis/taciturn
src/test/java/io/taciturn/utility/ArrayUtilityTest.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Set; import java.util.Vector; import java.util.stream.Stream; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.assertThat; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class ArrayUtilityTest { @Test public void testToSet() throws Exception {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/test/java/io/taciturn/utility/ArrayUtilityTest.java import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Set; import java.util.Vector; import java.util.stream.Stream; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.Assert.assertThat; import static io.taciturn.Utility.$; package io.taciturn.utility; public class ArrayUtilityTest { @Test public void testToSet() throws Exception {
assertThat($((String) null).toSet(), equalTo(new HashSet<>()));
timothymdavis/taciturn
src/test/java/io/taciturn/utility/CharacterUtilityTest.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import org.junit.Assert; import org.junit.Test; import static io.taciturn.Utility.$; import static org.hamcrest.core.Is.is;
package io.taciturn.utility; public class CharacterUtilityTest { @Test public void testToString() throws Exception {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/test/java/io/taciturn/utility/CharacterUtilityTest.java import org.junit.Assert; import org.junit.Test; import static io.taciturn.Utility.$; import static org.hamcrest.core.Is.is; package io.taciturn.utility; public class CharacterUtilityTest { @Test public void testToString() throws Exception {
Assert.assertThat($('a').toString(), is("a"));
timothymdavis/taciturn
src/main/java/io/taciturn/utility/MethodUtility.java
// Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class MethodUtility extends ObjectUtility<Method> { public static final Predicate<Method> IS_PUBLIC_METHOD = o -> Modifier.isPublic(o.getModifiers()); public static final Predicate<Method> IS_PRIVATE_METHOD = o -> Modifier.isPrivate(o.getModifiers()); public static final Predicate<Method> IS_PROTECTED_METHOD = o -> Modifier.isProtected(o.getModifiers()); public static final Predicate<Method> IS_GETTER = o -> o.getParameterCount() == 0 && o.getName().startsWith("get"); public static final Predicate<Method> IS_SETTER = o -> o.getParameterCount() == 1 && o.getName().startsWith("set"); private final Object parent; public MethodUtility(Method object, Object parent) { super(object); this.parent = parent; } /** * @see Method#toString() */ @Override public String toString() { return map(Method::toString).orElse(null); } /** * @see Method#invoke(Object, Object...) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException * @throws InvocationTargetException This checked exception is thrown by the {@link Rethrower}. */ @SuppressWarnings({ "JavaDoc", "unchecked" }) public <T> T invoke(Object... arguments) { return wrap(o -> (T) o.invoke(parent, arguments)); } public void makeAccessible() {
// Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/MethodUtility.java import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$; package io.taciturn.utility; public class MethodUtility extends ObjectUtility<Method> { public static final Predicate<Method> IS_PUBLIC_METHOD = o -> Modifier.isPublic(o.getModifiers()); public static final Predicate<Method> IS_PRIVATE_METHOD = o -> Modifier.isPrivate(o.getModifiers()); public static final Predicate<Method> IS_PROTECTED_METHOD = o -> Modifier.isProtected(o.getModifiers()); public static final Predicate<Method> IS_GETTER = o -> o.getParameterCount() == 0 && o.getName().startsWith("get"); public static final Predicate<Method> IS_SETTER = o -> o.getParameterCount() == 1 && o.getName().startsWith("set"); private final Object parent; public MethodUtility(Method object, Object parent) { super(object); this.parent = parent; } /** * @see Method#toString() */ @Override public String toString() { return map(Method::toString).orElse(null); } /** * @see Method#invoke(Object, Object...) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException * @throws InvocationTargetException This checked exception is thrown by the {@link Rethrower}. */ @SuppressWarnings({ "JavaDoc", "unchecked" }) public <T> T invoke(Object... arguments) { return wrap(o -> (T) o.invoke(parent, arguments)); } public void makeAccessible() {
ifPresent(method -> $(method).filter(m -> !Modifier.isPublic(m.getModifiers()) ||
timothymdavis/taciturn
src/main/java/io/taciturn/utility/MethodUtility.java
// Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class MethodUtility extends ObjectUtility<Method> { public static final Predicate<Method> IS_PUBLIC_METHOD = o -> Modifier.isPublic(o.getModifiers()); public static final Predicate<Method> IS_PRIVATE_METHOD = o -> Modifier.isPrivate(o.getModifiers()); public static final Predicate<Method> IS_PROTECTED_METHOD = o -> Modifier.isProtected(o.getModifiers()); public static final Predicate<Method> IS_GETTER = o -> o.getParameterCount() == 0 && o.getName().startsWith("get"); public static final Predicate<Method> IS_SETTER = o -> o.getParameterCount() == 1 && o.getName().startsWith("set"); private final Object parent; public MethodUtility(Method object, Object parent) { super(object); this.parent = parent; } /** * @see Method#toString() */ @Override public String toString() { return map(Method::toString).orElse(null); } /** * @see Method#invoke(Object, Object...) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException * @throws InvocationTargetException This checked exception is thrown by the {@link Rethrower}. */ @SuppressWarnings({ "JavaDoc", "unchecked" }) public <T> T invoke(Object... arguments) { return wrap(o -> (T) o.invoke(parent, arguments)); } public void makeAccessible() { ifPresent(method -> $(method).filter(m -> !Modifier.isPublic(m.getModifiers()) || !Modifier.isPublic(m.getDeclaringClass().getModifiers())) .filter(m -> !m.isAccessible()) .ifPresent(m -> m.setAccessible(true))); }
// Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/MethodUtility.java import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$; package io.taciturn.utility; public class MethodUtility extends ObjectUtility<Method> { public static final Predicate<Method> IS_PUBLIC_METHOD = o -> Modifier.isPublic(o.getModifiers()); public static final Predicate<Method> IS_PRIVATE_METHOD = o -> Modifier.isPrivate(o.getModifiers()); public static final Predicate<Method> IS_PROTECTED_METHOD = o -> Modifier.isProtected(o.getModifiers()); public static final Predicate<Method> IS_GETTER = o -> o.getParameterCount() == 0 && o.getName().startsWith("get"); public static final Predicate<Method> IS_SETTER = o -> o.getParameterCount() == 1 && o.getName().startsWith("set"); private final Object parent; public MethodUtility(Method object, Object parent) { super(object); this.parent = parent; } /** * @see Method#toString() */ @Override public String toString() { return map(Method::toString).orElse(null); } /** * @see Method#invoke(Object, Object...) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException * @throws InvocationTargetException This checked exception is thrown by the {@link Rethrower}. */ @SuppressWarnings({ "JavaDoc", "unchecked" }) public <T> T invoke(Object... arguments) { return wrap(o -> (T) o.invoke(parent, arguments)); } public void makeAccessible() { ifPresent(method -> $(method).filter(m -> !Modifier.isPublic(m.getModifiers()) || !Modifier.isPublic(m.getDeclaringClass().getModifiers())) .filter(m -> !m.isAccessible()) .ifPresent(m -> m.setAccessible(true))); }
private <T> T wrap(CheckedFunction<Method, T> function) {
timothymdavis/taciturn
src/main/java/io/taciturn/utility/MethodUtility.java
// Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class MethodUtility extends ObjectUtility<Method> { public static final Predicate<Method> IS_PUBLIC_METHOD = o -> Modifier.isPublic(o.getModifiers()); public static final Predicate<Method> IS_PRIVATE_METHOD = o -> Modifier.isPrivate(o.getModifiers()); public static final Predicate<Method> IS_PROTECTED_METHOD = o -> Modifier.isProtected(o.getModifiers()); public static final Predicate<Method> IS_GETTER = o -> o.getParameterCount() == 0 && o.getName().startsWith("get"); public static final Predicate<Method> IS_SETTER = o -> o.getParameterCount() == 1 && o.getName().startsWith("set"); private final Object parent; public MethodUtility(Method object, Object parent) { super(object); this.parent = parent; } /** * @see Method#toString() */ @Override public String toString() { return map(Method::toString).orElse(null); } /** * @see Method#invoke(Object, Object...) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException * @throws InvocationTargetException This checked exception is thrown by the {@link Rethrower}. */ @SuppressWarnings({ "JavaDoc", "unchecked" }) public <T> T invoke(Object... arguments) { return wrap(o -> (T) o.invoke(parent, arguments)); } public void makeAccessible() { ifPresent(method -> $(method).filter(m -> !Modifier.isPublic(m.getModifiers()) || !Modifier.isPublic(m.getDeclaringClass().getModifiers())) .filter(m -> !m.isAccessible()) .ifPresent(m -> m.setAccessible(true))); } private <T> T wrap(CheckedFunction<Method, T> function) { makeAccessible();
// Path: src/main/java/io/taciturn/function/CheckedFunction.java // @FunctionalInterface // public interface CheckedFunction<T, R> { // // R apply(T t) throws Throwable; // // } // // Path: src/main/java/io/taciturn/function/Rethrower.java // @SuppressWarnings("WeakerAccess") // public class Rethrower { // // public static <T> T rethrow(CheckedCallable<T> callable) { // return rethrowFunction(o -> callable.call(), null); // } // // public static <T> void rethrow(CheckedConsumer<T> consumer, T consumerParameter) { // rethrowFunction(o -> { // consumer.accept(o); // return (Void) null; // }, consumerParameter); // } // // public static <A, B> B rethrow(CheckedFunction<A, B> function, A functionParameter) { // return Rethrower.rethrowFunction(function, functionParameter); // } // // public static void rethrow(Throwable throwable) { // Rethrower.rethrowCheckedThrowable(throwable); // } // // @SuppressWarnings("ConstantConditions") // private static <A, B> B rethrowFunction(CheckedFunction<A, B> function, A functionParameter) { // try { // return function.apply(functionParameter); // } catch (Throwable e) { // Rethrower.rethrow(e); // throw new IllegalStateException(e); // } // } // // @SuppressWarnings({"unchecked", "ConstantConditions"}) // private static <T extends Throwable> void rethrowCheckedThrowable(@NonNull Throwable throwable) throws T { // throw (T) throwable; // } // // } // // Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/MethodUtility.java import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.function.Predicate; import io.taciturn.function.CheckedFunction; import io.taciturn.function.Rethrower; import static io.taciturn.Utility.$; package io.taciturn.utility; public class MethodUtility extends ObjectUtility<Method> { public static final Predicate<Method> IS_PUBLIC_METHOD = o -> Modifier.isPublic(o.getModifiers()); public static final Predicate<Method> IS_PRIVATE_METHOD = o -> Modifier.isPrivate(o.getModifiers()); public static final Predicate<Method> IS_PROTECTED_METHOD = o -> Modifier.isProtected(o.getModifiers()); public static final Predicate<Method> IS_GETTER = o -> o.getParameterCount() == 0 && o.getName().startsWith("get"); public static final Predicate<Method> IS_SETTER = o -> o.getParameterCount() == 1 && o.getName().startsWith("set"); private final Object parent; public MethodUtility(Method object, Object parent) { super(object); this.parent = parent; } /** * @see Method#toString() */ @Override public String toString() { return map(Method::toString).orElse(null); } /** * @see Method#invoke(Object, Object...) * @throws IllegalAccessException This checked exception is thrown by the {@link Rethrower}. * @throws IllegalArgumentException * @throws InvocationTargetException This checked exception is thrown by the {@link Rethrower}. */ @SuppressWarnings({ "JavaDoc", "unchecked" }) public <T> T invoke(Object... arguments) { return wrap(o -> (T) o.invoke(parent, arguments)); } public void makeAccessible() { ifPresent(method -> $(method).filter(m -> !Modifier.isPublic(m.getModifiers()) || !Modifier.isPublic(m.getDeclaringClass().getModifiers())) .filter(m -> !m.isAccessible()) .ifPresent(m -> m.setAccessible(true))); } private <T> T wrap(CheckedFunction<Method, T> function) { makeAccessible();
return map(o -> Rethrower.rethrow(function, o)).orElse(null);
timothymdavis/taciturn
src/main/java/io/taciturn/utility/AbstractUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.util.Objects; import java.util.Optional; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import static io.taciturn.Utility.$;
package io.taciturn.utility; @SuppressWarnings("WeakerAccess") public abstract class AbstractUtility<Item> { @SuppressWarnings("OptionalUsedAsFieldOrParameterType") private Optional<Item> object; public AbstractUtility(Item object) { this.object = Optional.ofNullable(object); } public boolean isPresent() { return object.isPresent(); } public void ifPresent(Consumer<? super Item> consumer) { object.ifPresent(consumer); } @SuppressWarnings("unchecked") public <T extends AbstractUtility<Item>> T filter(Predicate<? super Item> predicate) { object = object.filter(predicate); return (T) this; } @SuppressWarnings("unchecked") public <U> AbstractUtility<U> map(Function<? super Item, ? extends U> mapper) {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/AbstractUtility.java import java.util.Objects; import java.util.Optional; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; import static io.taciturn.Utility.$; package io.taciturn.utility; @SuppressWarnings("WeakerAccess") public abstract class AbstractUtility<Item> { @SuppressWarnings("OptionalUsedAsFieldOrParameterType") private Optional<Item> object; public AbstractUtility(Item object) { this.object = Optional.ofNullable(object); } public boolean isPresent() { return object.isPresent(); } public void ifPresent(Consumer<? super Item> consumer) { object.ifPresent(consumer); } @SuppressWarnings("unchecked") public <T extends AbstractUtility<Item>> T filter(Predicate<? super Item> predicate) { object = object.filter(predicate); return (T) this; } @SuppressWarnings("unchecked") public <U> AbstractUtility<U> map(Function<? super Item, ? extends U> mapper) {
return $(this.object.map(mapper).orElse(null));
timothymdavis/taciturn
src/test/java/io/taciturn/UtilityTest.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.util.ArrayList; import java.util.Collection; import java.util.Optional; import java.util.stream.Stream; import org.junit.Assert; import org.junit.Test; import static io.taciturn.Utility.$; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.hamcrest.core.IsNull.nullValue;
package io.taciturn; public class UtilityTest { @Test public void test$ClassUtility() throws Exception {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/test/java/io/taciturn/UtilityTest.java import java.util.ArrayList; import java.util.Collection; import java.util.Optional; import java.util.stream.Stream; import org.junit.Assert; import org.junit.Test; import static io.taciturn.Utility.$; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.hamcrest.core.IsNull.nullValue; package io.taciturn; public class UtilityTest { @Test public void test$ClassUtility() throws Exception {
Assert.assertThat($(String.class).get(), instanceOf(Class.class));
timothymdavis/taciturn
src/main/java/io/taciturn/utility/CharacterUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import static io.taciturn.Utility.$;
package io.taciturn.utility; public class CharacterUtility extends ComparableUtility<Character> { public static final char DEFAULT_VALUE = '\u0000'; public CharacterUtility(Character object) { super(object); } @Override public String toString() { return map(o -> Character.toString(o)).orElse(null); } public StringUtility mapToString() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/CharacterUtility.java import static io.taciturn.Utility.$; package io.taciturn.utility; public class CharacterUtility extends ComparableUtility<Character> { public static final char DEFAULT_VALUE = '\u0000'; public CharacterUtility(Character object) { super(object); } @Override public String toString() { return map(o -> Character.toString(o)).orElse(null); } public StringUtility mapToString() {
return $(toString());
timothymdavis/taciturn
src/main/java/io/taciturn/utility/BooleanUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import static io.taciturn.Utility.$;
package io.taciturn.utility; public class BooleanUtility extends ComparableUtility<Boolean> { public static final boolean DEFAULT_VALUE = false; public BooleanUtility(Boolean object) { super(object); } @Override public String toString() { return map(o -> Boolean.toString(o)).orElse(null); } public StringUtility mapToString() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/BooleanUtility.java import static io.taciturn.Utility.$; package io.taciturn.utility; public class BooleanUtility extends ComparableUtility<Boolean> { public static final boolean DEFAULT_VALUE = false; public BooleanUtility(Boolean object) { super(object); } @Override public String toString() { return map(o -> Boolean.toString(o)).orElse(null); } public StringUtility mapToString() {
return $(toString());
timothymdavis/taciturn
src/main/java/io/taciturn/utility/ComparableUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.util.function.Predicate; import static io.taciturn.Utility.$;
public ComparableUtility<Item> mustBeBetween(Item lower, Item upper) { return mustBe(isBetweenPredicate(lower, upper), createBetweenExpectedMessage(lower, upper)); } public ComparableUtility<Item> mustBeBetween(ComparableUtility<Item> lower, ComparableUtility<Item> upper) { return mustBe(isBetweenPredicate(lower, upper), createBetweenExpectedMessage(lower, upper)); } public ComparableUtility<Item> mustBeGreaterThan(Item lower) { return mustBe(isGreaterThanPredicate(lower), createGreaterThanExpectedMessage(lower)); } public ComparableUtility<Item> mustBeGreaterThanOrEqualTo(Item lower) { return mustBe(isGreaterThanOrEqualToPredicate(lower), createGreaterThanOrEqualToExpectedMessage(lower)); } public ComparableUtility<Item> mustBeLessThan(Item upper) { return mustBe(isLessThanPredicate(upper), createLessThanExpectedMessage(upper)); } public ComparableUtility<Item> mustBeLessThanOrEqualTo(Item upper) { return mustBe(isLessThanOrEqualToPredicate(upper), createLessThanOrEqualToExpectedMessage(upper)); } public ComparableUtility<Item> mustBeEqualTo(Item upper) { return mustBe(isEqualToPredicate(upper), createEqualToExpectedMessage(upper)); } public static <T extends Comparable<T>> Predicate<T> isBetweenPredicate(T lower, T upper) {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/ComparableUtility.java import java.util.function.Predicate; import static io.taciturn.Utility.$; public ComparableUtility<Item> mustBeBetween(Item lower, Item upper) { return mustBe(isBetweenPredicate(lower, upper), createBetweenExpectedMessage(lower, upper)); } public ComparableUtility<Item> mustBeBetween(ComparableUtility<Item> lower, ComparableUtility<Item> upper) { return mustBe(isBetweenPredicate(lower, upper), createBetweenExpectedMessage(lower, upper)); } public ComparableUtility<Item> mustBeGreaterThan(Item lower) { return mustBe(isGreaterThanPredicate(lower), createGreaterThanExpectedMessage(lower)); } public ComparableUtility<Item> mustBeGreaterThanOrEqualTo(Item lower) { return mustBe(isGreaterThanOrEqualToPredicate(lower), createGreaterThanOrEqualToExpectedMessage(lower)); } public ComparableUtility<Item> mustBeLessThan(Item upper) { return mustBe(isLessThanPredicate(upper), createLessThanExpectedMessage(upper)); } public ComparableUtility<Item> mustBeLessThanOrEqualTo(Item upper) { return mustBe(isLessThanOrEqualToPredicate(upper), createLessThanOrEqualToExpectedMessage(upper)); } public ComparableUtility<Item> mustBeEqualTo(Item upper) { return mustBe(isEqualToPredicate(upper), createEqualToExpectedMessage(upper)); } public static <T extends Comparable<T>> Predicate<T> isBetweenPredicate(T lower, T upper) {
$(lower).mustNotBeNull();
timothymdavis/taciturn
src/test/java/io/taciturn/utility/ScratchTest.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.lang.reflect.Method; import java.util.Objects; import org.junit.Test; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class ScratchTest { @Test public void scratch() throws Exception {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/test/java/io/taciturn/utility/ScratchTest.java import java.lang.reflect.Method; import java.util.Objects; import org.junit.Test; import static io.taciturn.Utility.$; package io.taciturn.utility; public class ScratchTest { @Test public void scratch() throws Exception {
$("a", "3", "2")
timothymdavis/taciturn
src/main/java/io/taciturn/utility/StringUtility.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.time.Instant; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.Date; import java.util.function.Predicate; import java.util.function.Supplier; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class StringUtility extends ComparableUtility<String> { public static final Predicate<String> isEmptyPredicate = String::isEmpty; public static final Predicate<String> isBlankPredicate = o -> o.trim().isEmpty(); public StringUtility(String object) { super(object); } public StringUtility blank() { return filter(isBlankPredicate); } public Boolean toBoolean() { return map(Boolean::parseBoolean).orElse(null); } public BooleanUtility mapToBoolean() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/main/java/io/taciturn/utility/StringUtility.java import java.time.Instant; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.util.Date; import java.util.function.Predicate; import java.util.function.Supplier; import static io.taciturn.Utility.$; package io.taciturn.utility; public class StringUtility extends ComparableUtility<String> { public static final Predicate<String> isEmptyPredicate = String::isEmpty; public static final Predicate<String> isBlankPredicate = o -> o.trim().isEmpty(); public StringUtility(String object) { super(object); } public StringUtility blank() { return filter(isBlankPredicate); } public Boolean toBoolean() { return map(Boolean::parseBoolean).orElse(null); } public BooleanUtility mapToBoolean() {
return $(toBoolean());
timothymdavis/taciturn
src/test/java/io/taciturn/utility/StringUtilityTest.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import java.util.function.Supplier; import org.junit.Assert; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertThat; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class StringUtilityTest { @Test public void testBlank() throws Exception {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/test/java/io/taciturn/utility/StringUtilityTest.java import java.util.function.Supplier; import org.junit.Assert; import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertThat; import static io.taciturn.Utility.$; package io.taciturn.utility; public class StringUtilityTest { @Test public void testBlank() throws Exception {
assertThat($((String) null).blank().isPresent(), is(false));
timothymdavis/taciturn
src/test/java/io/taciturn/utility/ComparableUtilityTest.java
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // }
import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static io.taciturn.Utility.$;
package io.taciturn.utility; public class ComparableUtilityTest { @Test public void thisIntegerIsNotBetween1And10() {
// Path: src/main/java/io/taciturn/Utility.java // public static <Item> ClassUtility<Item> $(Class<Item> object) { // return new ClassUtility<>(object); // } // Path: src/test/java/io/taciturn/utility/ComparableUtilityTest.java import org.junit.Test; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static io.taciturn.Utility.$; package io.taciturn.utility; public class ComparableUtilityTest { @Test public void thisIntegerIsNotBetween1And10() {
assertThat($((Integer) null).isBetween(1, 10), is(false));
Protino/Fad-Flicks
app/src/main/java/com/calgen/prodek/fadflicks/Activity/ReviewDetailActivity.java
// Path: app/src/main/java/com/calgen/prodek/fadflicks/Fragment/ReviewDetailFragment.java // public class ReviewDetailFragment extends Fragment { // //@formatter:off // @BindView(R.id.review_author) public TextView reviewAuthor; // @BindView(R.id.review_text) public TextView reviewText; // //@formatter:on // private Review review; // // @Override // public void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // review = (Review) getArguments().getSerializable(Intent.EXTRA_TEXT); // } // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // View rootView = inflater.inflate(R.layout.review_detail, container, false); // ButterKnife.bind(this, rootView); // reviewAuthor.setText(review.getAuthor()); // reviewText.setText(review.getContent()); // Linkify.addLinks(reviewText, Linkify.ALL); // return rootView; // } // } // // Path: app/src/main/java/com/calgen/prodek/fadflicks/model/Review.java // public class Review implements Serializable{ // // @SerializedName("id") // @Expose // private String id; // @SerializedName("author") // @Expose // private String author; // @SerializedName("content") // @Expose // private String content; // @SerializedName("url") // @Expose // private String url; // // /** // * No args constructor for use in serialization // * // */ // public Review() { // } // // /** // * // * @param content // * @param id // * @param author // * @param url // */ // public Review(String id, String author, String content, String url) { // this.id = id; // this.author = author; // this.content = content; // this.url = url; // } // // /** // * // * @return // * The id // */ // public String getId() { // return id; // } // // /** // * // * @param id // * The id // */ // public void setId(String id) { // this.id = id; // } // // /** // * // * @return // * The author // */ // public String getAuthor() { // return author; // } // // /** // * // * @param author // * The author // */ // public void setAuthor(String author) { // this.author = author; // } // // /** // * // * @return // * The content // */ // public String getContent() { // return content; // } // // /** // * // * @param content // * The content // */ // public void setContent(String content) { // this.content = content; // } // // /** // * // * @return // * The url // */ // public String getUrl() { // return url; // } // // /** // * // * @param url // * The url // */ // public void setUrl(String url) { // this.url = url; // } // // }
import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import com.calgen.prodek.fadflicks.R; import com.calgen.prodek.fadflicks.fragment.ReviewDetailFragment; import com.calgen.prodek.fadflicks.model.Review; import butterknife.BindView; import butterknife.ButterKnife;
/* * Copyright 2016 Gurupad Mamadapur * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.calgen.prodek.fadflicks.activity; /** * Created by Gurupad Mamadapur on 10/31/2016. */ public class ReviewDetailActivity extends AppCompatActivity { //@formatter:off @BindView(R.id.toolbar) public Toolbar toolbar; //@formatter:on @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_review_detail); ButterKnife.bind(this);
// Path: app/src/main/java/com/calgen/prodek/fadflicks/Fragment/ReviewDetailFragment.java // public class ReviewDetailFragment extends Fragment { // //@formatter:off // @BindView(R.id.review_author) public TextView reviewAuthor; // @BindView(R.id.review_text) public TextView reviewText; // //@formatter:on // private Review review; // // @Override // public void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // review = (Review) getArguments().getSerializable(Intent.EXTRA_TEXT); // } // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // View rootView = inflater.inflate(R.layout.review_detail, container, false); // ButterKnife.bind(this, rootView); // reviewAuthor.setText(review.getAuthor()); // reviewText.setText(review.getContent()); // Linkify.addLinks(reviewText, Linkify.ALL); // return rootView; // } // } // // Path: app/src/main/java/com/calgen/prodek/fadflicks/model/Review.java // public class Review implements Serializable{ // // @SerializedName("id") // @Expose // private String id; // @SerializedName("author") // @Expose // private String author; // @SerializedName("content") // @Expose // private String content; // @SerializedName("url") // @Expose // private String url; // // /** // * No args constructor for use in serialization // * // */ // public Review() { // } // // /** // * // * @param content // * @param id // * @param author // * @param url // */ // public Review(String id, String author, String content, String url) { // this.id = id; // this.author = author; // this.content = content; // this.url = url; // } // // /** // * // * @return // * The id // */ // public String getId() { // return id; // } // // /** // * // * @param id // * The id // */ // public void setId(String id) { // this.id = id; // } // // /** // * // * @return // * The author // */ // public String getAuthor() { // return author; // } // // /** // * // * @param author // * The author // */ // public void setAuthor(String author) { // this.author = author; // } // // /** // * // * @return // * The content // */ // public String getContent() { // return content; // } // // /** // * // * @param content // * The content // */ // public void setContent(String content) { // this.content = content; // } // // /** // * // * @return // * The url // */ // public String getUrl() { // return url; // } // // /** // * // * @param url // * The url // */ // public void setUrl(String url) { // this.url = url; // } // // } // Path: app/src/main/java/com/calgen/prodek/fadflicks/Activity/ReviewDetailActivity.java import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import com.calgen.prodek.fadflicks.R; import com.calgen.prodek.fadflicks.fragment.ReviewDetailFragment; import com.calgen.prodek.fadflicks.model.Review; import butterknife.BindView; import butterknife.ButterKnife; /* * Copyright 2016 Gurupad Mamadapur * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.calgen.prodek.fadflicks.activity; /** * Created by Gurupad Mamadapur on 10/31/2016. */ public class ReviewDetailActivity extends AppCompatActivity { //@formatter:off @BindView(R.id.toolbar) public Toolbar toolbar; //@formatter:on @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_review_detail); ButterKnife.bind(this);
Review review = (Review) getIntent().getSerializableExtra(Intent.EXTRA_TEXT);
Protino/Fad-Flicks
app/src/main/java/com/calgen/prodek/fadflicks/Activity/ReviewDetailActivity.java
// Path: app/src/main/java/com/calgen/prodek/fadflicks/Fragment/ReviewDetailFragment.java // public class ReviewDetailFragment extends Fragment { // //@formatter:off // @BindView(R.id.review_author) public TextView reviewAuthor; // @BindView(R.id.review_text) public TextView reviewText; // //@formatter:on // private Review review; // // @Override // public void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // review = (Review) getArguments().getSerializable(Intent.EXTRA_TEXT); // } // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // View rootView = inflater.inflate(R.layout.review_detail, container, false); // ButterKnife.bind(this, rootView); // reviewAuthor.setText(review.getAuthor()); // reviewText.setText(review.getContent()); // Linkify.addLinks(reviewText, Linkify.ALL); // return rootView; // } // } // // Path: app/src/main/java/com/calgen/prodek/fadflicks/model/Review.java // public class Review implements Serializable{ // // @SerializedName("id") // @Expose // private String id; // @SerializedName("author") // @Expose // private String author; // @SerializedName("content") // @Expose // private String content; // @SerializedName("url") // @Expose // private String url; // // /** // * No args constructor for use in serialization // * // */ // public Review() { // } // // /** // * // * @param content // * @param id // * @param author // * @param url // */ // public Review(String id, String author, String content, String url) { // this.id = id; // this.author = author; // this.content = content; // this.url = url; // } // // /** // * // * @return // * The id // */ // public String getId() { // return id; // } // // /** // * // * @param id // * The id // */ // public void setId(String id) { // this.id = id; // } // // /** // * // * @return // * The author // */ // public String getAuthor() { // return author; // } // // /** // * // * @param author // * The author // */ // public void setAuthor(String author) { // this.author = author; // } // // /** // * // * @return // * The content // */ // public String getContent() { // return content; // } // // /** // * // * @param content // * The content // */ // public void setContent(String content) { // this.content = content; // } // // /** // * // * @return // * The url // */ // public String getUrl() { // return url; // } // // /** // * // * @param url // * The url // */ // public void setUrl(String url) { // this.url = url; // } // // }
import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import com.calgen.prodek.fadflicks.R; import com.calgen.prodek.fadflicks.fragment.ReviewDetailFragment; import com.calgen.prodek.fadflicks.model.Review; import butterknife.BindView; import butterknife.ButterKnife;
/* * Copyright 2016 Gurupad Mamadapur * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.calgen.prodek.fadflicks.activity; /** * Created by Gurupad Mamadapur on 10/31/2016. */ public class ReviewDetailActivity extends AppCompatActivity { //@formatter:off @BindView(R.id.toolbar) public Toolbar toolbar; //@formatter:on @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_review_detail); ButterKnife.bind(this); Review review = (Review) getIntent().getSerializableExtra(Intent.EXTRA_TEXT); toolbar.setTitle(getIntent().getStringExtra(getString(R.string.movie_title_key))); setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Path: app/src/main/java/com/calgen/prodek/fadflicks/Fragment/ReviewDetailFragment.java // public class ReviewDetailFragment extends Fragment { // //@formatter:off // @BindView(R.id.review_author) public TextView reviewAuthor; // @BindView(R.id.review_text) public TextView reviewText; // //@formatter:on // private Review review; // // @Override // public void onCreate(@Nullable Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // review = (Review) getArguments().getSerializable(Intent.EXTRA_TEXT); // } // // // @Override // public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // View rootView = inflater.inflate(R.layout.review_detail, container, false); // ButterKnife.bind(this, rootView); // reviewAuthor.setText(review.getAuthor()); // reviewText.setText(review.getContent()); // Linkify.addLinks(reviewText, Linkify.ALL); // return rootView; // } // } // // Path: app/src/main/java/com/calgen/prodek/fadflicks/model/Review.java // public class Review implements Serializable{ // // @SerializedName("id") // @Expose // private String id; // @SerializedName("author") // @Expose // private String author; // @SerializedName("content") // @Expose // private String content; // @SerializedName("url") // @Expose // private String url; // // /** // * No args constructor for use in serialization // * // */ // public Review() { // } // // /** // * // * @param content // * @param id // * @param author // * @param url // */ // public Review(String id, String author, String content, String url) { // this.id = id; // this.author = author; // this.content = content; // this.url = url; // } // // /** // * // * @return // * The id // */ // public String getId() { // return id; // } // // /** // * // * @param id // * The id // */ // public void setId(String id) { // this.id = id; // } // // /** // * // * @return // * The author // */ // public String getAuthor() { // return author; // } // // /** // * // * @param author // * The author // */ // public void setAuthor(String author) { // this.author = author; // } // // /** // * // * @return // * The content // */ // public String getContent() { // return content; // } // // /** // * // * @param content // * The content // */ // public void setContent(String content) { // this.content = content; // } // // /** // * // * @return // * The url // */ // public String getUrl() { // return url; // } // // /** // * // * @param url // * The url // */ // public void setUrl(String url) { // this.url = url; // } // // } // Path: app/src/main/java/com/calgen/prodek/fadflicks/Activity/ReviewDetailActivity.java import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import com.calgen.prodek.fadflicks.R; import com.calgen.prodek.fadflicks.fragment.ReviewDetailFragment; import com.calgen.prodek.fadflicks.model.Review; import butterknife.BindView; import butterknife.ButterKnife; /* * Copyright 2016 Gurupad Mamadapur * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.calgen.prodek.fadflicks.activity; /** * Created by Gurupad Mamadapur on 10/31/2016. */ public class ReviewDetailActivity extends AppCompatActivity { //@formatter:off @BindView(R.id.toolbar) public Toolbar toolbar; //@formatter:on @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_review_detail); ButterKnife.bind(this); Review review = (Review) getIntent().getSerializableExtra(Intent.EXTRA_TEXT); toolbar.setTitle(getIntent().getStringExtra(getString(R.string.movie_title_key))); setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ReviewDetailFragment reviewDetailFragment = new ReviewDetailFragment();
Protino/Fad-Flicks
app/src/main/java/com/calgen/prodek/fadflicks/utils/UI.java
// Path: app/src/main/java/com/calgen/prodek/fadflicks/Adapter/ReviewAdapter.java // public class ReviewAdapter extends ArrayAdapter<Review> { // private Context context; // private List<Review> reviewList; // private boolean glimpse; // // public ReviewAdapter(Context context, ArrayList<Review> reviewList, boolean glimpse) { // super(context, 0, reviewList); // this.context = context; // this.reviewList = reviewList; // this.glimpse = glimpse; // } // // @Override // public int getCount() { // int size = reviewList.size(); // int reviewLimit = 3; // if (glimpse) // return (size > 2) ? reviewLimit : size; // else // return size; // } // // @NonNull // @Override // public View getView(int position, View convertView, @NonNull ViewGroup parent) { // // Review review = reviewList.get(position); // ViewHolder viewHolder; // // if (convertView == null) { // LayoutInflater layoutInflater = LayoutInflater.from(context); // convertView = layoutInflater.inflate(R.layout.list_item_review, parent, false); // viewHolder = new ViewHolder(convertView); // // convertView.setTag(viewHolder); // } else { // viewHolder = (ViewHolder) convertView.getTag(); // } // // if (glimpse) { // viewHolder.reviewText.setMaxLines(3); // viewHolder.reviewText.setEllipsize(TextUtils.TruncateAt.END); // viewHolder.listItemLayout.setEnabled(false); // viewHolder.listItemLayout.setLongClickable(false); // } // // viewHolder.author.setText(review.getAuthor()); // viewHolder.reviewText.setText(review.getContent()); // viewHolder.author.setTag(position); // viewHolder.reviewText.setTag(position); // return convertView; // } // // class ViewHolder { // // //@formatter:off // @BindView(R.id.review_author) public TextView author; // @BindView(R.id.review_text) public TextView reviewText; // @BindView(R.id.list_item_layout) public LinearLayout listItemLayout; // //@formatter:on // // ViewHolder(View view) { // ButterKnife.bind(this, view); // } // } // }
import android.content.Context; import android.content.res.Resources; import android.util.DisplayMetrics; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.ListView; import com.calgen.prodek.fadflicks.adapter.ReviewAdapter;
/* * Copyright 2016 Gurupad Mamadapur * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.calgen.prodek.fadflicks.utils; /** * Created by Gurupad Mamadapur on 10/30/2016. */ public class UI { /** * @param dp dp value * @return converted px value */ public static int dpToPx(int dp) { DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics(); return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); } /** * @param px dp value * @return converted dp value */ public static int pxToDp(int px) { DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics(); return Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); } /** * Change the height of the listView embedded in scrollview based on its children so that * * @param listView ListView whose height needs modification */ public static void setListViewHeightBasedOnChildren(ListView listView) {
// Path: app/src/main/java/com/calgen/prodek/fadflicks/Adapter/ReviewAdapter.java // public class ReviewAdapter extends ArrayAdapter<Review> { // private Context context; // private List<Review> reviewList; // private boolean glimpse; // // public ReviewAdapter(Context context, ArrayList<Review> reviewList, boolean glimpse) { // super(context, 0, reviewList); // this.context = context; // this.reviewList = reviewList; // this.glimpse = glimpse; // } // // @Override // public int getCount() { // int size = reviewList.size(); // int reviewLimit = 3; // if (glimpse) // return (size > 2) ? reviewLimit : size; // else // return size; // } // // @NonNull // @Override // public View getView(int position, View convertView, @NonNull ViewGroup parent) { // // Review review = reviewList.get(position); // ViewHolder viewHolder; // // if (convertView == null) { // LayoutInflater layoutInflater = LayoutInflater.from(context); // convertView = layoutInflater.inflate(R.layout.list_item_review, parent, false); // viewHolder = new ViewHolder(convertView); // // convertView.setTag(viewHolder); // } else { // viewHolder = (ViewHolder) convertView.getTag(); // } // // if (glimpse) { // viewHolder.reviewText.setMaxLines(3); // viewHolder.reviewText.setEllipsize(TextUtils.TruncateAt.END); // viewHolder.listItemLayout.setEnabled(false); // viewHolder.listItemLayout.setLongClickable(false); // } // // viewHolder.author.setText(review.getAuthor()); // viewHolder.reviewText.setText(review.getContent()); // viewHolder.author.setTag(position); // viewHolder.reviewText.setTag(position); // return convertView; // } // // class ViewHolder { // // //@formatter:off // @BindView(R.id.review_author) public TextView author; // @BindView(R.id.review_text) public TextView reviewText; // @BindView(R.id.list_item_layout) public LinearLayout listItemLayout; // //@formatter:on // // ViewHolder(View view) { // ButterKnife.bind(this, view); // } // } // } // Path: app/src/main/java/com/calgen/prodek/fadflicks/utils/UI.java import android.content.Context; import android.content.res.Resources; import android.util.DisplayMetrics; import android.view.View; import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.ListView; import com.calgen.prodek.fadflicks.adapter.ReviewAdapter; /* * Copyright 2016 Gurupad Mamadapur * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.calgen.prodek.fadflicks.utils; /** * Created by Gurupad Mamadapur on 10/30/2016. */ public class UI { /** * @param dp dp value * @return converted px value */ public static int dpToPx(int dp) { DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics(); return Math.round(dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); } /** * @param px dp value * @return converted dp value */ public static int pxToDp(int px) { DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics(); return Math.round(px / (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)); } /** * Change the height of the listView embedded in scrollview based on its children so that * * @param listView ListView whose height needs modification */ public static void setListViewHeightBasedOnChildren(ListView listView) {
ReviewAdapter listAdapter = (ReviewAdapter) listView.getAdapter();
Protino/Fad-Flicks
app/src/main/java/com/calgen/prodek/fadflicks/Fragment/ReviewDetailFragment.java
// Path: app/src/main/java/com/calgen/prodek/fadflicks/model/Review.java // public class Review implements Serializable{ // // @SerializedName("id") // @Expose // private String id; // @SerializedName("author") // @Expose // private String author; // @SerializedName("content") // @Expose // private String content; // @SerializedName("url") // @Expose // private String url; // // /** // * No args constructor for use in serialization // * // */ // public Review() { // } // // /** // * // * @param content // * @param id // * @param author // * @param url // */ // public Review(String id, String author, String content, String url) { // this.id = id; // this.author = author; // this.content = content; // this.url = url; // } // // /** // * // * @return // * The id // */ // public String getId() { // return id; // } // // /** // * // * @param id // * The id // */ // public void setId(String id) { // this.id = id; // } // // /** // * // * @return // * The author // */ // public String getAuthor() { // return author; // } // // /** // * // * @param author // * The author // */ // public void setAuthor(String author) { // this.author = author; // } // // /** // * // * @return // * The content // */ // public String getContent() { // return content; // } // // /** // * // * @param content // * The content // */ // public void setContent(String content) { // this.content = content; // } // // /** // * // * @return // * The url // */ // public String getUrl() { // return url; // } // // /** // * // * @param url // * The url // */ // public void setUrl(String url) { // this.url = url; // } // // }
import butterknife.ButterKnife; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.text.util.Linkify; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.calgen.prodek.fadflicks.R; import com.calgen.prodek.fadflicks.model.Review; import butterknife.BindView;
/* * Copyright 2016 Gurupad Mamadapur * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.calgen.prodek.fadflicks.fragment; /** * Placeholder fragment to display review details. */ public class ReviewDetailFragment extends Fragment { //@formatter:off @BindView(R.id.review_author) public TextView reviewAuthor; @BindView(R.id.review_text) public TextView reviewText; //@formatter:on
// Path: app/src/main/java/com/calgen/prodek/fadflicks/model/Review.java // public class Review implements Serializable{ // // @SerializedName("id") // @Expose // private String id; // @SerializedName("author") // @Expose // private String author; // @SerializedName("content") // @Expose // private String content; // @SerializedName("url") // @Expose // private String url; // // /** // * No args constructor for use in serialization // * // */ // public Review() { // } // // /** // * // * @param content // * @param id // * @param author // * @param url // */ // public Review(String id, String author, String content, String url) { // this.id = id; // this.author = author; // this.content = content; // this.url = url; // } // // /** // * // * @return // * The id // */ // public String getId() { // return id; // } // // /** // * // * @param id // * The id // */ // public void setId(String id) { // this.id = id; // } // // /** // * // * @return // * The author // */ // public String getAuthor() { // return author; // } // // /** // * // * @param author // * The author // */ // public void setAuthor(String author) { // this.author = author; // } // // /** // * // * @return // * The content // */ // public String getContent() { // return content; // } // // /** // * // * @param content // * The content // */ // public void setContent(String content) { // this.content = content; // } // // /** // * // * @return // * The url // */ // public String getUrl() { // return url; // } // // /** // * // * @param url // * The url // */ // public void setUrl(String url) { // this.url = url; // } // // } // Path: app/src/main/java/com/calgen/prodek/fadflicks/Fragment/ReviewDetailFragment.java import butterknife.ButterKnife; import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.text.util.Linkify; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import com.calgen.prodek.fadflicks.R; import com.calgen.prodek.fadflicks.model.Review; import butterknife.BindView; /* * Copyright 2016 Gurupad Mamadapur * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.calgen.prodek.fadflicks.fragment; /** * Placeholder fragment to display review details. */ public class ReviewDetailFragment extends Fragment { //@formatter:off @BindView(R.id.review_author) public TextView reviewAuthor; @BindView(R.id.review_text) public TextView reviewText; //@formatter:on
private Review review;
Protino/Fad-Flicks
app/src/main/java/com/calgen/prodek/fadflicks/api/ApiClient.java
// Path: app/src/main/java/com/calgen/prodek/fadflicks/utils/ApplicationConstants.java // public class ApplicationConstants { // // /** // * Set to true if debugging is needed // */ // public static final boolean DEBUG = false; // // /** // * When true, forces to clear defaultSharedPreferences // */ // public static final boolean PURGE_CACHE = false; // // public static final int CACHE_PURGE_PERIOD = 24*60*60*100; // // /** // * API Endpoint // */ // public static final String END_POINT = "http://api.themoviedb.org/3/"; // /** // * Connection timeout duration // */ // public static final int CONNECT_TIMEOUT = 60 * 1000; // /** // * Connection Read timeout duration // */ // public static final int READ_TIMEOUT = 60 * 1000; // /** // * Connection write timeout duration // */ // public static final int WRITE_TIMEOUT = 60 * 1000; // // }
import com.calgen.prodek.fadflicks.utils.ApplicationConstants; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory;
/* * Copyright 2016 Gurupad Mamadapur * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.calgen.prodek.fadflicks.api; /** * =========== * Acknowledgement * =========== * Thanks to Thomas kioko for the tutorial * on using interceptors * * @see <a href="http://www.thomaskioko.com/mobile_phone/android-unit-testing/">Blog post</a> */ public class ApiClient { private Retrofit retrofit; private boolean isDebug; private HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(); /** * Set the {@link Retrofit} log level. * * @param isDebug If true, the log level is set to * {@link HttpLoggingInterceptor.Level#BODY}. Otherwise * {@link HttpLoggingInterceptor.Level#NONE}. */ public ApiClient setIsDebug(boolean isDebug) { this.isDebug = isDebug; if (retrofit != null) { httpLoggingInterceptor. setLevel(isDebug ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE); } return this; } /** * Configure OkHttpClient * * @return OkHttpClient */ private OkHttpClient okHttpClient() { return new OkHttpClient.Builder() .addInterceptor(new AuthInterceptor())
// Path: app/src/main/java/com/calgen/prodek/fadflicks/utils/ApplicationConstants.java // public class ApplicationConstants { // // /** // * Set to true if debugging is needed // */ // public static final boolean DEBUG = false; // // /** // * When true, forces to clear defaultSharedPreferences // */ // public static final boolean PURGE_CACHE = false; // // public static final int CACHE_PURGE_PERIOD = 24*60*60*100; // // /** // * API Endpoint // */ // public static final String END_POINT = "http://api.themoviedb.org/3/"; // /** // * Connection timeout duration // */ // public static final int CONNECT_TIMEOUT = 60 * 1000; // /** // * Connection Read timeout duration // */ // public static final int READ_TIMEOUT = 60 * 1000; // /** // * Connection write timeout duration // */ // public static final int WRITE_TIMEOUT = 60 * 1000; // // } // Path: app/src/main/java/com/calgen/prodek/fadflicks/api/ApiClient.java import com.calgen.prodek.fadflicks.utils.ApplicationConstants; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; import okhttp3.logging.HttpLoggingInterceptor; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; /* * Copyright 2016 Gurupad Mamadapur * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.calgen.prodek.fadflicks.api; /** * =========== * Acknowledgement * =========== * Thanks to Thomas kioko for the tutorial * on using interceptors * * @see <a href="http://www.thomaskioko.com/mobile_phone/android-unit-testing/">Blog post</a> */ public class ApiClient { private Retrofit retrofit; private boolean isDebug; private HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(); /** * Set the {@link Retrofit} log level. * * @param isDebug If true, the log level is set to * {@link HttpLoggingInterceptor.Level#BODY}. Otherwise * {@link HttpLoggingInterceptor.Level#NONE}. */ public ApiClient setIsDebug(boolean isDebug) { this.isDebug = isDebug; if (retrofit != null) { httpLoggingInterceptor. setLevel(isDebug ? HttpLoggingInterceptor.Level.BODY : HttpLoggingInterceptor.Level.NONE); } return this; } /** * Configure OkHttpClient * * @return OkHttpClient */ private OkHttpClient okHttpClient() { return new OkHttpClient.Builder() .addInterceptor(new AuthInterceptor())
.connectTimeout(ApplicationConstants.CONNECT_TIMEOUT, TimeUnit.SECONDS)
tfreier/desktop-crm
src/main/java/net/combase/desktopcrm/data/LeadImporter.java
// Path: src/main/java/net/combase/desktopcrm/domain/Campaign.java // public class Campaign extends AbstractCrmObject // { // // public Campaign(String id, String title) // { // super(id, title); // } // // @Override // public String getCrmEntityType() // { // return "Campaigns"; // } // // } // // Path: src/main/java/net/combase/desktopcrm/domain/Lead.java // public class Lead extends AbstractCrmObject implements HasEmail // { // private String email; // // private String firstname; // // private String lastName; // // private String accountName; // // private String campaignId; // // private String type; // // private String description; // // private String jobTitle; // // private String phone; // // private String address; // // private String city; // // private String state; // // private String zip; // // private String country; // // private String mobile; // // public Lead() // { // super(); // } // // public Lead(String id, String title) // { // super(id, title); // } // // // public String getMobile() // { // return mobile; // } // // public void setMobile(String mobile) // { // this.mobile = mobile; // } // // @Override // public String getEmail() // { // return email; // } // // public void setEmail(String email) // { // this.email = email; // } // // @Override // public String getFirstname() // { // return firstname; // } // // public void setFirstname(String firstname) // { // this.firstname = firstname; // } // // public String getLastName() // { // return lastName; // } // // public void setLastName(String lastName) // { // this.lastName = lastName; // } // // public String getAccountName() // { // return accountName; // } // // public void setAccountName(String accountName) // { // this.accountName = accountName; // } // // public String getCampaignId() // { // return campaignId; // } // // public void setCampaignId(String campaignId) // { // this.campaignId = campaignId; // } // // public String getType() // { // return type; // } // // public void setType(String type) // { // this.type = type; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public String getJobTitle() // { // return jobTitle; // } // // public void setJobTitle(String title) // { // this.jobTitle = title; // } // // public String getPhone() // { // return phone; // } // // public void setPhone(String phone) // { // this.phone = phone; // } // // public String getAddress() // { // return address; // } // // public void setAddress(String address) // { // this.address = address; // } // // public String getCity() // { // return city; // } // // public void setCity(String city) // { // this.city = city; // } // // public String getState() // { // return state; // } // // public void setState(String state) // { // this.state = state; // } // // public String getZip() // { // return zip; // } // // public void setZip(String zip) // { // this.zip = zip; // } // // public String getCountry() // { // return country; // } // // public void setCountry(String country) // { // this.country = country; // } // // @Override // public String getCrmEntityType() // { // return "Leads"; // } // // // }
import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVRecord; import net.combase.desktopcrm.domain.Campaign; import net.combase.desktopcrm.domain.Lead;
/** * */ package net.combase.desktopcrm.data; /** * @author "Till Freier" */ public class LeadImporter {
// Path: src/main/java/net/combase/desktopcrm/domain/Campaign.java // public class Campaign extends AbstractCrmObject // { // // public Campaign(String id, String title) // { // super(id, title); // } // // @Override // public String getCrmEntityType() // { // return "Campaigns"; // } // // } // // Path: src/main/java/net/combase/desktopcrm/domain/Lead.java // public class Lead extends AbstractCrmObject implements HasEmail // { // private String email; // // private String firstname; // // private String lastName; // // private String accountName; // // private String campaignId; // // private String type; // // private String description; // // private String jobTitle; // // private String phone; // // private String address; // // private String city; // // private String state; // // private String zip; // // private String country; // // private String mobile; // // public Lead() // { // super(); // } // // public Lead(String id, String title) // { // super(id, title); // } // // // public String getMobile() // { // return mobile; // } // // public void setMobile(String mobile) // { // this.mobile = mobile; // } // // @Override // public String getEmail() // { // return email; // } // // public void setEmail(String email) // { // this.email = email; // } // // @Override // public String getFirstname() // { // return firstname; // } // // public void setFirstname(String firstname) // { // this.firstname = firstname; // } // // public String getLastName() // { // return lastName; // } // // public void setLastName(String lastName) // { // this.lastName = lastName; // } // // public String getAccountName() // { // return accountName; // } // // public void setAccountName(String accountName) // { // this.accountName = accountName; // } // // public String getCampaignId() // { // return campaignId; // } // // public void setCampaignId(String campaignId) // { // this.campaignId = campaignId; // } // // public String getType() // { // return type; // } // // public void setType(String type) // { // this.type = type; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public String getJobTitle() // { // return jobTitle; // } // // public void setJobTitle(String title) // { // this.jobTitle = title; // } // // public String getPhone() // { // return phone; // } // // public void setPhone(String phone) // { // this.phone = phone; // } // // public String getAddress() // { // return address; // } // // public void setAddress(String address) // { // this.address = address; // } // // public String getCity() // { // return city; // } // // public void setCity(String city) // { // this.city = city; // } // // public String getState() // { // return state; // } // // public void setState(String state) // { // this.state = state; // } // // public String getZip() // { // return zip; // } // // public void setZip(String zip) // { // this.zip = zip; // } // // public String getCountry() // { // return country; // } // // public void setCountry(String country) // { // this.country = country; // } // // @Override // public String getCrmEntityType() // { // return "Leads"; // } // // // } // Path: src/main/java/net/combase/desktopcrm/data/LeadImporter.java import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVRecord; import net.combase.desktopcrm.domain.Campaign; import net.combase.desktopcrm.domain.Lead; /** * */ package net.combase.desktopcrm.data; /** * @author "Till Freier" */ public class LeadImporter {
public static Collection<Lead> importFile(File f)
tfreier/desktop-crm
src/main/java/net/combase/desktopcrm/data/LeadImporter.java
// Path: src/main/java/net/combase/desktopcrm/domain/Campaign.java // public class Campaign extends AbstractCrmObject // { // // public Campaign(String id, String title) // { // super(id, title); // } // // @Override // public String getCrmEntityType() // { // return "Campaigns"; // } // // } // // Path: src/main/java/net/combase/desktopcrm/domain/Lead.java // public class Lead extends AbstractCrmObject implements HasEmail // { // private String email; // // private String firstname; // // private String lastName; // // private String accountName; // // private String campaignId; // // private String type; // // private String description; // // private String jobTitle; // // private String phone; // // private String address; // // private String city; // // private String state; // // private String zip; // // private String country; // // private String mobile; // // public Lead() // { // super(); // } // // public Lead(String id, String title) // { // super(id, title); // } // // // public String getMobile() // { // return mobile; // } // // public void setMobile(String mobile) // { // this.mobile = mobile; // } // // @Override // public String getEmail() // { // return email; // } // // public void setEmail(String email) // { // this.email = email; // } // // @Override // public String getFirstname() // { // return firstname; // } // // public void setFirstname(String firstname) // { // this.firstname = firstname; // } // // public String getLastName() // { // return lastName; // } // // public void setLastName(String lastName) // { // this.lastName = lastName; // } // // public String getAccountName() // { // return accountName; // } // // public void setAccountName(String accountName) // { // this.accountName = accountName; // } // // public String getCampaignId() // { // return campaignId; // } // // public void setCampaignId(String campaignId) // { // this.campaignId = campaignId; // } // // public String getType() // { // return type; // } // // public void setType(String type) // { // this.type = type; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public String getJobTitle() // { // return jobTitle; // } // // public void setJobTitle(String title) // { // this.jobTitle = title; // } // // public String getPhone() // { // return phone; // } // // public void setPhone(String phone) // { // this.phone = phone; // } // // public String getAddress() // { // return address; // } // // public void setAddress(String address) // { // this.address = address; // } // // public String getCity() // { // return city; // } // // public void setCity(String city) // { // this.city = city; // } // // public String getState() // { // return state; // } // // public void setState(String state) // { // this.state = state; // } // // public String getZip() // { // return zip; // } // // public void setZip(String zip) // { // this.zip = zip; // } // // public String getCountry() // { // return country; // } // // public void setCountry(String country) // { // this.country = country; // } // // @Override // public String getCrmEntityType() // { // return "Leads"; // } // // // }
import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVRecord; import net.combase.desktopcrm.domain.Campaign; import net.combase.desktopcrm.domain.Lead;
/** * */ package net.combase.desktopcrm.data; /** * @author "Till Freier" */ public class LeadImporter { public static Collection<Lead> importFile(File f) { try { Iterable<CSVRecord> records = CSVFormat.EXCEL.parse(new FileReader(f)); Iterator<CSVRecord> lines = records.iterator(); if (!lines.hasNext()) return null; CSVRecord headerRow = lines.next(); List<Lead> leads = new ArrayList<>(); while (lines.hasNext()) { final Iterator<String> content = lines.next().iterator(); final Iterator<String> header = headerRow.iterator(); Lead lead = new Lead(null, "new lead"); StringBuilder desc = new StringBuilder(); // use capterra as default campaign since it doesn't reference // itself in the import file
// Path: src/main/java/net/combase/desktopcrm/domain/Campaign.java // public class Campaign extends AbstractCrmObject // { // // public Campaign(String id, String title) // { // super(id, title); // } // // @Override // public String getCrmEntityType() // { // return "Campaigns"; // } // // } // // Path: src/main/java/net/combase/desktopcrm/domain/Lead.java // public class Lead extends AbstractCrmObject implements HasEmail // { // private String email; // // private String firstname; // // private String lastName; // // private String accountName; // // private String campaignId; // // private String type; // // private String description; // // private String jobTitle; // // private String phone; // // private String address; // // private String city; // // private String state; // // private String zip; // // private String country; // // private String mobile; // // public Lead() // { // super(); // } // // public Lead(String id, String title) // { // super(id, title); // } // // // public String getMobile() // { // return mobile; // } // // public void setMobile(String mobile) // { // this.mobile = mobile; // } // // @Override // public String getEmail() // { // return email; // } // // public void setEmail(String email) // { // this.email = email; // } // // @Override // public String getFirstname() // { // return firstname; // } // // public void setFirstname(String firstname) // { // this.firstname = firstname; // } // // public String getLastName() // { // return lastName; // } // // public void setLastName(String lastName) // { // this.lastName = lastName; // } // // public String getAccountName() // { // return accountName; // } // // public void setAccountName(String accountName) // { // this.accountName = accountName; // } // // public String getCampaignId() // { // return campaignId; // } // // public void setCampaignId(String campaignId) // { // this.campaignId = campaignId; // } // // public String getType() // { // return type; // } // // public void setType(String type) // { // this.type = type; // } // // public String getDescription() // { // return description; // } // // public void setDescription(String description) // { // this.description = description; // } // // public String getJobTitle() // { // return jobTitle; // } // // public void setJobTitle(String title) // { // this.jobTitle = title; // } // // public String getPhone() // { // return phone; // } // // public void setPhone(String phone) // { // this.phone = phone; // } // // public String getAddress() // { // return address; // } // // public void setAddress(String address) // { // this.address = address; // } // // public String getCity() // { // return city; // } // // public void setCity(String city) // { // this.city = city; // } // // public String getState() // { // return state; // } // // public void setState(String state) // { // this.state = state; // } // // public String getZip() // { // return zip; // } // // public void setZip(String zip) // { // this.zip = zip; // } // // public String getCountry() // { // return country; // } // // public void setCountry(String country) // { // this.country = country; // } // // @Override // public String getCrmEntityType() // { // return "Leads"; // } // // // } // Path: src/main/java/net/combase/desktopcrm/data/LeadImporter.java import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVRecord; import net.combase.desktopcrm.domain.Campaign; import net.combase.desktopcrm.domain.Lead; /** * */ package net.combase.desktopcrm.data; /** * @author "Till Freier" */ public class LeadImporter { public static Collection<Lead> importFile(File f) { try { Iterable<CSVRecord> records = CSVFormat.EXCEL.parse(new FileReader(f)); Iterator<CSVRecord> lines = records.iterator(); if (!lines.hasNext()) return null; CSVRecord headerRow = lines.next(); List<Lead> leads = new ArrayList<>(); while (lines.hasNext()) { final Iterator<String> content = lines.next().iterator(); final Iterator<String> header = headerRow.iterator(); Lead lead = new Lead(null, "new lead"); StringBuilder desc = new StringBuilder(); // use capterra as default campaign since it doesn't reference // itself in the import file
Campaign camp = CrmManager.getCampaignByName("Capterra");
tfreier/desktop-crm
src/main/java/net/combase/desktopcrm/swing/EmailTemplateTableModel.java
// Path: src/main/java/net/combase/desktopcrm/domain/EmailTemplate.java // public class EmailTemplate extends AbstractCrmObject { // // private String body; // private String htmlBody; // private String subject; // // public EmailTemplate(String id, String title) { // super(id, title); // } // // // public String getHtmlBody() // { // return htmlBody; // } // // // public void setHtmlBody(String htmlBody) // { // this.htmlBody = htmlBody; // } // // // public String getBody() // { // return body; // } // // public void setBody(String body) // { // this.body = body; // } // // public String getSubject() // { // return subject; // } // // public void setSubject(String subject) // { // this.subject = subject; // } // // // @Override // public String getCrmEntityType() // { // return "EmailTemplates"; // } // // // }
import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Collection; import java.util.List; import javax.swing.JButton; import javax.swing.table.AbstractTableModel; import net.combase.desktopcrm.domain.EmailTemplate;
/** * */ package net.combase.desktopcrm.swing; /** * @author "Till Freier" * */ public class EmailTemplateTableModel extends AbstractTableModel { /** * */ private static final long serialVersionUID = -3890791456083674319L; private static final String[] COLUMN_NAMES = new String[] { "Template", "", "" }; private static final Class<?>[] COLUMN_TYPES = new Class<?>[] { String.class, JButton.class, JButton.class };
// Path: src/main/java/net/combase/desktopcrm/domain/EmailTemplate.java // public class EmailTemplate extends AbstractCrmObject { // // private String body; // private String htmlBody; // private String subject; // // public EmailTemplate(String id, String title) { // super(id, title); // } // // // public String getHtmlBody() // { // return htmlBody; // } // // // public void setHtmlBody(String htmlBody) // { // this.htmlBody = htmlBody; // } // // // public String getBody() // { // return body; // } // // public void setBody(String body) // { // this.body = body; // } // // public String getSubject() // { // return subject; // } // // public void setSubject(String subject) // { // this.subject = subject; // } // // // @Override // public String getCrmEntityType() // { // return "EmailTemplates"; // } // // // } // Path: src/main/java/net/combase/desktopcrm/swing/EmailTemplateTableModel.java import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Collection; import java.util.List; import javax.swing.JButton; import javax.swing.table.AbstractTableModel; import net.combase.desktopcrm.domain.EmailTemplate; /** * */ package net.combase.desktopcrm.swing; /** * @author "Till Freier" * */ public class EmailTemplateTableModel extends AbstractTableModel { /** * */ private static final long serialVersionUID = -3890791456083674319L; private static final String[] COLUMN_NAMES = new String[] { "Template", "", "" }; private static final Class<?>[] COLUMN_TYPES = new Class<?>[] { String.class, JButton.class, JButton.class };
private final List<EmailTemplate> data;
tfreier/desktop-crm
src/main/java/net/combase/desktopcrm/data/AsteriskManager.java
// Path: src/main/java/net/combase/desktopcrm/domain/Settings.java // public class Settings implements Serializable // { // /** // * // */ // private static final long serialVersionUID = -2756760963012353808L; // private String crmUrl; // private String user; // private String password; // private int gmtOffset = 0; // private String accountCriteria; // private String asteriskHost; // private String asteriskUser; // private String asteriskPassword; // private String asteriskExtension; // // private String dialUrl; // // private boolean callReminder = true; // private boolean meetingReminder = true; // private boolean taskReminder = true; // private boolean leadReminder = true; // private boolean opportunityReminder = true; // private boolean caseReminder = true; // // public boolean isMeetingReminder() // { // return meetingReminder; // } // // public void setMeetingReminder(boolean meetingReminder) // { // this.meetingReminder = meetingReminder; // } // // public String getDialUrl() // { // return dialUrl; // } // // public void setDialUrl(String dialUrl) // { // this.dialUrl = dialUrl; // } // // public String getAsteriskHost() // { // return asteriskHost; // } // // public void setAsteriskHost(String asteriskHost) // { // this.asteriskHost = asteriskHost; // } // // public String getAsteriskUser() // { // return asteriskUser; // } // // public void setAsteriskUser(String asteriskUser) // { // this.asteriskUser = asteriskUser; // } // // public String getAsteriskPassword() // { // return asteriskPassword; // } // // public void setAsteriskPassword(String asteriskPassword) // { // this.asteriskPassword = asteriskPassword; // } // // public String getAsteriskExtension() // { // return asteriskExtension; // } // // public void setAsteriskExtension(String asteriskExtension) // { // this.asteriskExtension = asteriskExtension; // } // // public boolean isCallReminder() // { // return callReminder; // } // // public void setCallReminder(boolean callReminder) // { // this.callReminder = callReminder; // } // // public boolean isTaskReminder() // { // return taskReminder; // } // // public void setTaskReminder(boolean taskReminder) // { // this.taskReminder = taskReminder; // } // // public boolean isLeadReminder() // { // return leadReminder; // } // // public void setLeadReminder(boolean leadReminder) // { // this.leadReminder = leadReminder; // } // // public boolean isOpportunityReminder() // { // return opportunityReminder; // } // // public void setOpportunityReminder(boolean opportunityReminder) // { // this.opportunityReminder = opportunityReminder; // } // // public boolean isCaseReminder() // { // return caseReminder; // } // // public void setCaseReminder(boolean caseReminder) // { // this.caseReminder = caseReminder; // } // // public String getAccountCriteria() // { // return accountCriteria; // } // // public void setAccountCriteria(String accountCriteria) // { // this.accountCriteria = accountCriteria; // } // // public int getGmtOffset() // { // return gmtOffset; // } // // public void setGmtOffset(int gmtOffset) // { // this.gmtOffset = gmtOffset; // } // // public String getCrmUrl() // { // return crmUrl; // } // // public void setCrmUrl(String crmUrl) // { // this.crmUrl = crmUrl; // } // // public String getUser() // { // return user; // } // // public void setUser(String user) // { // this.user = user; // } // // public String getPassword() // { // return password; // } // // public void setPassword(String password) // { // this.password = password; // } // // }
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpResponse; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.HttpClientBuilder; import org.asteriskjava.live.AsteriskChannel; import org.asteriskjava.live.AsteriskServer; import org.asteriskjava.live.AsteriskServerListener; import org.asteriskjava.live.CallerId; import org.asteriskjava.live.DefaultAsteriskServer; import org.asteriskjava.live.Extension; import org.asteriskjava.live.ManagerCommunicationException; import org.asteriskjava.live.MeetMeUser; import net.combase.desktopcrm.domain.Settings;
/** * */ package net.combase.desktopcrm.data; /** * yealink call url: * http://10.1.0.11/cgi-bin/ConfigManApp.com?number= * * @author "Till Freier" */ public final class AsteriskManager { public interface AsteriskCallEventListener { public void incomingCall(String number); public void outgoingCall(String number); } private static AsteriskServer asteriskServer = null; private static String extension = ""; private static List<AsteriskCallEventListener> listeners = new ArrayList<>(); private AsteriskManager() { super(); } public static void dial(String number) {
// Path: src/main/java/net/combase/desktopcrm/domain/Settings.java // public class Settings implements Serializable // { // /** // * // */ // private static final long serialVersionUID = -2756760963012353808L; // private String crmUrl; // private String user; // private String password; // private int gmtOffset = 0; // private String accountCriteria; // private String asteriskHost; // private String asteriskUser; // private String asteriskPassword; // private String asteriskExtension; // // private String dialUrl; // // private boolean callReminder = true; // private boolean meetingReminder = true; // private boolean taskReminder = true; // private boolean leadReminder = true; // private boolean opportunityReminder = true; // private boolean caseReminder = true; // // public boolean isMeetingReminder() // { // return meetingReminder; // } // // public void setMeetingReminder(boolean meetingReminder) // { // this.meetingReminder = meetingReminder; // } // // public String getDialUrl() // { // return dialUrl; // } // // public void setDialUrl(String dialUrl) // { // this.dialUrl = dialUrl; // } // // public String getAsteriskHost() // { // return asteriskHost; // } // // public void setAsteriskHost(String asteriskHost) // { // this.asteriskHost = asteriskHost; // } // // public String getAsteriskUser() // { // return asteriskUser; // } // // public void setAsteriskUser(String asteriskUser) // { // this.asteriskUser = asteriskUser; // } // // public String getAsteriskPassword() // { // return asteriskPassword; // } // // public void setAsteriskPassword(String asteriskPassword) // { // this.asteriskPassword = asteriskPassword; // } // // public String getAsteriskExtension() // { // return asteriskExtension; // } // // public void setAsteriskExtension(String asteriskExtension) // { // this.asteriskExtension = asteriskExtension; // } // // public boolean isCallReminder() // { // return callReminder; // } // // public void setCallReminder(boolean callReminder) // { // this.callReminder = callReminder; // } // // public boolean isTaskReminder() // { // return taskReminder; // } // // public void setTaskReminder(boolean taskReminder) // { // this.taskReminder = taskReminder; // } // // public boolean isLeadReminder() // { // return leadReminder; // } // // public void setLeadReminder(boolean leadReminder) // { // this.leadReminder = leadReminder; // } // // public boolean isOpportunityReminder() // { // return opportunityReminder; // } // // public void setOpportunityReminder(boolean opportunityReminder) // { // this.opportunityReminder = opportunityReminder; // } // // public boolean isCaseReminder() // { // return caseReminder; // } // // public void setCaseReminder(boolean caseReminder) // { // this.caseReminder = caseReminder; // } // // public String getAccountCriteria() // { // return accountCriteria; // } // // public void setAccountCriteria(String accountCriteria) // { // this.accountCriteria = accountCriteria; // } // // public int getGmtOffset() // { // return gmtOffset; // } // // public void setGmtOffset(int gmtOffset) // { // this.gmtOffset = gmtOffset; // } // // public String getCrmUrl() // { // return crmUrl; // } // // public void setCrmUrl(String crmUrl) // { // this.crmUrl = crmUrl; // } // // public String getUser() // { // return user; // } // // public void setUser(String user) // { // this.user = user; // } // // public String getPassword() // { // return password; // } // // public void setPassword(String password) // { // this.password = password; // } // // } // Path: src/main/java/net/combase/desktopcrm/data/AsteriskManager.java import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.apache.http.HttpResponse; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.HttpClientBuilder; import org.asteriskjava.live.AsteriskChannel; import org.asteriskjava.live.AsteriskServer; import org.asteriskjava.live.AsteriskServerListener; import org.asteriskjava.live.CallerId; import org.asteriskjava.live.DefaultAsteriskServer; import org.asteriskjava.live.Extension; import org.asteriskjava.live.ManagerCommunicationException; import org.asteriskjava.live.MeetMeUser; import net.combase.desktopcrm.domain.Settings; /** * */ package net.combase.desktopcrm.data; /** * yealink call url: * http://10.1.0.11/cgi-bin/ConfigManApp.com?number= * * @author "Till Freier" */ public final class AsteriskManager { public interface AsteriskCallEventListener { public void incomingCall(String number); public void outgoingCall(String number); } private static AsteriskServer asteriskServer = null; private static String extension = ""; private static List<AsteriskCallEventListener> listeners = new ArrayList<>(); private AsteriskManager() { super(); } public static void dial(String number) {
final Settings settings = DataStoreManager.getSettings();
tfreier/desktop-crm
src/main/java/net/combase/desktopcrm/swing/DataSelectionEventManager.java
// Path: src/main/java/net/combase/desktopcrm/domain/AbstractCrmObject.java // public abstract class AbstractCrmObject // { // private String id; // // private String viewUrl; // // private String editUrl; // // private String relatedObjectType; // // private String relatedObjectUrl; // // private String relatedObjectId; // // private String title; // // private String activitiesUrl; // // // /** // * @return the activitiesUrl // */ // public String getActivitiesUrl() // { // return activitiesUrl; // } // // // /** // * @param activitiesUrl the activitiesUrl to set // */ // public void setActivitiesUrl(String activitiesUrl) // { // this.activitiesUrl = activitiesUrl; // } // // // private String assignedUser; // // // public String getAssignedUser() // { // return assignedUser; // } // // // public void setAssignedUser(String assignedUser) // { // this.assignedUser = assignedUser; // } // // // public abstract String getCrmEntityType(); // // // public String getRelatedObjectId() // { // return relatedObjectId; // } // // // public void setRelatedObjectId(String relatedObjectId) // { // this.relatedObjectId = relatedObjectId; // } // // // public AbstractCrmObject() // { // super(); // } // // // public AbstractCrmObject(String id, String title) // { // super(); // this.id = id; // this.title = title; // } // // // public String getId() // { // return id; // } // // // public String getViewUrl() // { // return viewUrl; // } // // // public void setViewUrl(String viewUrl) // { // this.viewUrl = viewUrl; // } // // // public String getEditUrl() // { // return editUrl; // } // // // public void setEditUrl(String editUrl) // { // this.editUrl = editUrl; // } // // // public String getRelatedObjectType() // { // return relatedObjectType; // } // // // public void setRelatedObjectType(String relatedObjectType) // { // this.relatedObjectType = relatedObjectType; // } // // // public String getRelatedObjectUrl() // { // return relatedObjectUrl; // } // // // public void setRelatedObjectUrl(String realtedObjectUrl) // { // this.relatedObjectUrl = realtedObjectUrl; // } // // // public String getTitle() // { // return title; // } // // // public void setTitle(String title) // { // this.title = title; // } // // // @Override // public String toString() // { // return title; // } // // }
import net.combase.desktopcrm.domain.AbstractCrmObject;
/** * */ package net.combase.desktopcrm.swing; /** * @author "Till Freier" * */ public final class DataSelectionEventManager { public interface DataSelectionListener {
// Path: src/main/java/net/combase/desktopcrm/domain/AbstractCrmObject.java // public abstract class AbstractCrmObject // { // private String id; // // private String viewUrl; // // private String editUrl; // // private String relatedObjectType; // // private String relatedObjectUrl; // // private String relatedObjectId; // // private String title; // // private String activitiesUrl; // // // /** // * @return the activitiesUrl // */ // public String getActivitiesUrl() // { // return activitiesUrl; // } // // // /** // * @param activitiesUrl the activitiesUrl to set // */ // public void setActivitiesUrl(String activitiesUrl) // { // this.activitiesUrl = activitiesUrl; // } // // // private String assignedUser; // // // public String getAssignedUser() // { // return assignedUser; // } // // // public void setAssignedUser(String assignedUser) // { // this.assignedUser = assignedUser; // } // // // public abstract String getCrmEntityType(); // // // public String getRelatedObjectId() // { // return relatedObjectId; // } // // // public void setRelatedObjectId(String relatedObjectId) // { // this.relatedObjectId = relatedObjectId; // } // // // public AbstractCrmObject() // { // super(); // } // // // public AbstractCrmObject(String id, String title) // { // super(); // this.id = id; // this.title = title; // } // // // public String getId() // { // return id; // } // // // public String getViewUrl() // { // return viewUrl; // } // // // public void setViewUrl(String viewUrl) // { // this.viewUrl = viewUrl; // } // // // public String getEditUrl() // { // return editUrl; // } // // // public void setEditUrl(String editUrl) // { // this.editUrl = editUrl; // } // // // public String getRelatedObjectType() // { // return relatedObjectType; // } // // // public void setRelatedObjectType(String relatedObjectType) // { // this.relatedObjectType = relatedObjectType; // } // // // public String getRelatedObjectUrl() // { // return relatedObjectUrl; // } // // // public void setRelatedObjectUrl(String realtedObjectUrl) // { // this.relatedObjectUrl = realtedObjectUrl; // } // // // public String getTitle() // { // return title; // } // // // public void setTitle(String title) // { // this.title = title; // } // // // @Override // public String toString() // { // return title; // } // // } // Path: src/main/java/net/combase/desktopcrm/swing/DataSelectionEventManager.java import net.combase.desktopcrm.domain.AbstractCrmObject; /** * */ package net.combase.desktopcrm.swing; /** * @author "Till Freier" * */ public final class DataSelectionEventManager { public interface DataSelectionListener {
public void dataSelected(AbstractCrmObject data);
tfreier/desktop-crm
src/main/java/net/combase/desktopcrm/swing/EmailTemplateTablePanel.java
// Path: src/main/java/net/combase/desktopcrm/data/CrmHelper.java // public final class CrmHelper // { // private CrmHelper() // { // } // // private static Collection<EmailTemplate> emailTemplateCache = null; // // // public static synchronized void updateEmailTemplateCache() // { // emailTemplateCache = new TreeSet<>(new Comparator<EmailTemplate>() // { // // @Override // public int compare(EmailTemplate o1, EmailTemplate o2) // { // return o1.getTitle().compareTo(o2.getTitle()); // } // }); // // emailTemplateCache.addAll(CrmManager.getEmailTemplateList()); // } // // // public static synchronized Collection<EmailTemplate> getCachedEmailTemplates() // { // if (emailTemplateCache == null) // { // updateEmailTemplateCache(); // } // // return emailTemplateCache; // } // // public static List<AbstractCrmObject> getActionObjects() // { // List<AbstractCrmObject> result = new ArrayList<>(); // List<AbstractCrmObject> checkList = new ArrayList<>(); // // if (DataStoreManager.getSettings().isCaseReminder()) // checkList.addAll(CrmManager.getCaseList()); // // if (DataStoreManager.getSettings().isOpportunityReminder()) // checkList.addAll(CrmManager.getOpportunityList()); // // if (DataStoreManager.getSettings().isLeadReminder()) // checkList.addAll(CrmManager.getLeadList()); // // // for (final AbstractCrmObject lead : checkList) // { // System.out.println("check " + lead.getTitle() + " for actions."); // if (!hasActionsPlanned(lead)) // result.add(lead); // } // System.out.println("found " + result.size() + " action items."); // return result; // } // // /** // * @param lead // * @return // */ // public static boolean hasActionsPlanned(final AbstractCrmObject lead) // { // boolean noAction = CrmManager.getOpenTaskListByParent(lead.getId()).isEmpty(); // // if (noAction) // noAction = CrmManager.getMeetingListByParent(lead.getId()).isEmpty(); // // if (noAction) // noAction = CrmManager.getCallListByParent(lead.getId()).isEmpty(); // // return !noAction; // } // // // public static List<AbstractCrmObject> getGlobalActionObjects() // { // List<AbstractCrmObject> result = new ArrayList<>(); // List<AbstractCrmObject> checkList = new ArrayList<>(); // // checkList.addAll(CrmManager.getGlobalCaseList()); // checkList.addAll(CrmManager.getGlobalOpportunityList()); // checkList.addAll(CrmManager.getGlobalLeadList()); // // for (final AbstractCrmObject lead : checkList) // { // System.out.println("check " + lead.getTitle() + " for actions."); // if (!hasActionsPlanned(lead)) // result.add(lead); // } // System.out.println("found " + result.size() + " action items."); // return result; // } // } // // Path: src/main/java/net/combase/desktopcrm/domain/EmailTemplate.java // public class EmailTemplate extends AbstractCrmObject { // // private String body; // private String htmlBody; // private String subject; // // public EmailTemplate(String id, String title) { // super(id, title); // } // // // public String getHtmlBody() // { // return htmlBody; // } // // // public void setHtmlBody(String htmlBody) // { // this.htmlBody = htmlBody; // } // // // public String getBody() // { // return body; // } // // public void setBody(String body) // { // this.body = body; // } // // public String getSubject() // { // return subject; // } // // public void setSubject(String subject) // { // this.subject = subject; // } // // // @Override // public String getCrmEntityType() // { // return "EmailTemplates"; // } // // // }
import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.table.TableCellRenderer; import net.combase.desktopcrm.data.CrmHelper; import net.combase.desktopcrm.domain.EmailTemplate;
package net.combase.desktopcrm.swing; public class EmailTemplateTablePanel extends JPanel { /** * */ private static final long serialVersionUID = -6149463410211475900L; private JTable table; /** * Create the panel. */ public EmailTemplateTablePanel() { setLayout(new BorderLayout(0, 0));
// Path: src/main/java/net/combase/desktopcrm/data/CrmHelper.java // public final class CrmHelper // { // private CrmHelper() // { // } // // private static Collection<EmailTemplate> emailTemplateCache = null; // // // public static synchronized void updateEmailTemplateCache() // { // emailTemplateCache = new TreeSet<>(new Comparator<EmailTemplate>() // { // // @Override // public int compare(EmailTemplate o1, EmailTemplate o2) // { // return o1.getTitle().compareTo(o2.getTitle()); // } // }); // // emailTemplateCache.addAll(CrmManager.getEmailTemplateList()); // } // // // public static synchronized Collection<EmailTemplate> getCachedEmailTemplates() // { // if (emailTemplateCache == null) // { // updateEmailTemplateCache(); // } // // return emailTemplateCache; // } // // public static List<AbstractCrmObject> getActionObjects() // { // List<AbstractCrmObject> result = new ArrayList<>(); // List<AbstractCrmObject> checkList = new ArrayList<>(); // // if (DataStoreManager.getSettings().isCaseReminder()) // checkList.addAll(CrmManager.getCaseList()); // // if (DataStoreManager.getSettings().isOpportunityReminder()) // checkList.addAll(CrmManager.getOpportunityList()); // // if (DataStoreManager.getSettings().isLeadReminder()) // checkList.addAll(CrmManager.getLeadList()); // // // for (final AbstractCrmObject lead : checkList) // { // System.out.println("check " + lead.getTitle() + " for actions."); // if (!hasActionsPlanned(lead)) // result.add(lead); // } // System.out.println("found " + result.size() + " action items."); // return result; // } // // /** // * @param lead // * @return // */ // public static boolean hasActionsPlanned(final AbstractCrmObject lead) // { // boolean noAction = CrmManager.getOpenTaskListByParent(lead.getId()).isEmpty(); // // if (noAction) // noAction = CrmManager.getMeetingListByParent(lead.getId()).isEmpty(); // // if (noAction) // noAction = CrmManager.getCallListByParent(lead.getId()).isEmpty(); // // return !noAction; // } // // // public static List<AbstractCrmObject> getGlobalActionObjects() // { // List<AbstractCrmObject> result = new ArrayList<>(); // List<AbstractCrmObject> checkList = new ArrayList<>(); // // checkList.addAll(CrmManager.getGlobalCaseList()); // checkList.addAll(CrmManager.getGlobalOpportunityList()); // checkList.addAll(CrmManager.getGlobalLeadList()); // // for (final AbstractCrmObject lead : checkList) // { // System.out.println("check " + lead.getTitle() + " for actions."); // if (!hasActionsPlanned(lead)) // result.add(lead); // } // System.out.println("found " + result.size() + " action items."); // return result; // } // } // // Path: src/main/java/net/combase/desktopcrm/domain/EmailTemplate.java // public class EmailTemplate extends AbstractCrmObject { // // private String body; // private String htmlBody; // private String subject; // // public EmailTemplate(String id, String title) { // super(id, title); // } // // // public String getHtmlBody() // { // return htmlBody; // } // // // public void setHtmlBody(String htmlBody) // { // this.htmlBody = htmlBody; // } // // // public String getBody() // { // return body; // } // // public void setBody(String body) // { // this.body = body; // } // // public String getSubject() // { // return subject; // } // // public void setSubject(String subject) // { // this.subject = subject; // } // // // @Override // public String getCrmEntityType() // { // return "EmailTemplates"; // } // // // } // Path: src/main/java/net/combase/desktopcrm/swing/EmailTemplateTablePanel.java import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.table.TableCellRenderer; import net.combase.desktopcrm.data.CrmHelper; import net.combase.desktopcrm.domain.EmailTemplate; package net.combase.desktopcrm.swing; public class EmailTemplateTablePanel extends JPanel { /** * */ private static final long serialVersionUID = -6149463410211475900L; private JTable table; /** * Create the panel. */ public EmailTemplateTablePanel() { setLayout(new BorderLayout(0, 0));
final EmailTemplateTableModel model = new EmailTemplateTableModel(new ArrayList<EmailTemplate>());
tfreier/desktop-crm
src/main/java/net/combase/desktopcrm/swing/EmailTemplateTablePanel.java
// Path: src/main/java/net/combase/desktopcrm/data/CrmHelper.java // public final class CrmHelper // { // private CrmHelper() // { // } // // private static Collection<EmailTemplate> emailTemplateCache = null; // // // public static synchronized void updateEmailTemplateCache() // { // emailTemplateCache = new TreeSet<>(new Comparator<EmailTemplate>() // { // // @Override // public int compare(EmailTemplate o1, EmailTemplate o2) // { // return o1.getTitle().compareTo(o2.getTitle()); // } // }); // // emailTemplateCache.addAll(CrmManager.getEmailTemplateList()); // } // // // public static synchronized Collection<EmailTemplate> getCachedEmailTemplates() // { // if (emailTemplateCache == null) // { // updateEmailTemplateCache(); // } // // return emailTemplateCache; // } // // public static List<AbstractCrmObject> getActionObjects() // { // List<AbstractCrmObject> result = new ArrayList<>(); // List<AbstractCrmObject> checkList = new ArrayList<>(); // // if (DataStoreManager.getSettings().isCaseReminder()) // checkList.addAll(CrmManager.getCaseList()); // // if (DataStoreManager.getSettings().isOpportunityReminder()) // checkList.addAll(CrmManager.getOpportunityList()); // // if (DataStoreManager.getSettings().isLeadReminder()) // checkList.addAll(CrmManager.getLeadList()); // // // for (final AbstractCrmObject lead : checkList) // { // System.out.println("check " + lead.getTitle() + " for actions."); // if (!hasActionsPlanned(lead)) // result.add(lead); // } // System.out.println("found " + result.size() + " action items."); // return result; // } // // /** // * @param lead // * @return // */ // public static boolean hasActionsPlanned(final AbstractCrmObject lead) // { // boolean noAction = CrmManager.getOpenTaskListByParent(lead.getId()).isEmpty(); // // if (noAction) // noAction = CrmManager.getMeetingListByParent(lead.getId()).isEmpty(); // // if (noAction) // noAction = CrmManager.getCallListByParent(lead.getId()).isEmpty(); // // return !noAction; // } // // // public static List<AbstractCrmObject> getGlobalActionObjects() // { // List<AbstractCrmObject> result = new ArrayList<>(); // List<AbstractCrmObject> checkList = new ArrayList<>(); // // checkList.addAll(CrmManager.getGlobalCaseList()); // checkList.addAll(CrmManager.getGlobalOpportunityList()); // checkList.addAll(CrmManager.getGlobalLeadList()); // // for (final AbstractCrmObject lead : checkList) // { // System.out.println("check " + lead.getTitle() + " for actions."); // if (!hasActionsPlanned(lead)) // result.add(lead); // } // System.out.println("found " + result.size() + " action items."); // return result; // } // } // // Path: src/main/java/net/combase/desktopcrm/domain/EmailTemplate.java // public class EmailTemplate extends AbstractCrmObject { // // private String body; // private String htmlBody; // private String subject; // // public EmailTemplate(String id, String title) { // super(id, title); // } // // // public String getHtmlBody() // { // return htmlBody; // } // // // public void setHtmlBody(String htmlBody) // { // this.htmlBody = htmlBody; // } // // // public String getBody() // { // return body; // } // // public void setBody(String body) // { // this.body = body; // } // // public String getSubject() // { // return subject; // } // // public void setSubject(String subject) // { // this.subject = subject; // } // // // @Override // public String getCrmEntityType() // { // return "EmailTemplates"; // } // // // }
import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.table.TableCellRenderer; import net.combase.desktopcrm.data.CrmHelper; import net.combase.desktopcrm.domain.EmailTemplate;
((JButton) value).doClick(); } } } }); table.setDefaultRenderer(JButton.class, new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (value instanceof JButton) { return (JButton) value; } return new JLabel(); } }); table.getColumnModel().getColumn(1).setMaxWidth(30); table.getColumnModel().getColumn(2).setMaxWidth(30); table.setRowHeight(30); add(table.getTableHeader(), BorderLayout.NORTH); add(new JScrollPane(table), BorderLayout.CENTER); UiUtil.runAndRepeat(new Runnable() { @Override public void run() {
// Path: src/main/java/net/combase/desktopcrm/data/CrmHelper.java // public final class CrmHelper // { // private CrmHelper() // { // } // // private static Collection<EmailTemplate> emailTemplateCache = null; // // // public static synchronized void updateEmailTemplateCache() // { // emailTemplateCache = new TreeSet<>(new Comparator<EmailTemplate>() // { // // @Override // public int compare(EmailTemplate o1, EmailTemplate o2) // { // return o1.getTitle().compareTo(o2.getTitle()); // } // }); // // emailTemplateCache.addAll(CrmManager.getEmailTemplateList()); // } // // // public static synchronized Collection<EmailTemplate> getCachedEmailTemplates() // { // if (emailTemplateCache == null) // { // updateEmailTemplateCache(); // } // // return emailTemplateCache; // } // // public static List<AbstractCrmObject> getActionObjects() // { // List<AbstractCrmObject> result = new ArrayList<>(); // List<AbstractCrmObject> checkList = new ArrayList<>(); // // if (DataStoreManager.getSettings().isCaseReminder()) // checkList.addAll(CrmManager.getCaseList()); // // if (DataStoreManager.getSettings().isOpportunityReminder()) // checkList.addAll(CrmManager.getOpportunityList()); // // if (DataStoreManager.getSettings().isLeadReminder()) // checkList.addAll(CrmManager.getLeadList()); // // // for (final AbstractCrmObject lead : checkList) // { // System.out.println("check " + lead.getTitle() + " for actions."); // if (!hasActionsPlanned(lead)) // result.add(lead); // } // System.out.println("found " + result.size() + " action items."); // return result; // } // // /** // * @param lead // * @return // */ // public static boolean hasActionsPlanned(final AbstractCrmObject lead) // { // boolean noAction = CrmManager.getOpenTaskListByParent(lead.getId()).isEmpty(); // // if (noAction) // noAction = CrmManager.getMeetingListByParent(lead.getId()).isEmpty(); // // if (noAction) // noAction = CrmManager.getCallListByParent(lead.getId()).isEmpty(); // // return !noAction; // } // // // public static List<AbstractCrmObject> getGlobalActionObjects() // { // List<AbstractCrmObject> result = new ArrayList<>(); // List<AbstractCrmObject> checkList = new ArrayList<>(); // // checkList.addAll(CrmManager.getGlobalCaseList()); // checkList.addAll(CrmManager.getGlobalOpportunityList()); // checkList.addAll(CrmManager.getGlobalLeadList()); // // for (final AbstractCrmObject lead : checkList) // { // System.out.println("check " + lead.getTitle() + " for actions."); // if (!hasActionsPlanned(lead)) // result.add(lead); // } // System.out.println("found " + result.size() + " action items."); // return result; // } // } // // Path: src/main/java/net/combase/desktopcrm/domain/EmailTemplate.java // public class EmailTemplate extends AbstractCrmObject { // // private String body; // private String htmlBody; // private String subject; // // public EmailTemplate(String id, String title) { // super(id, title); // } // // // public String getHtmlBody() // { // return htmlBody; // } // // // public void setHtmlBody(String htmlBody) // { // this.htmlBody = htmlBody; // } // // // public String getBody() // { // return body; // } // // public void setBody(String body) // { // this.body = body; // } // // public String getSubject() // { // return subject; // } // // public void setSubject(String subject) // { // this.subject = subject; // } // // // @Override // public String getCrmEntityType() // { // return "EmailTemplates"; // } // // // } // Path: src/main/java/net/combase/desktopcrm/swing/EmailTemplateTablePanel.java import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.table.TableCellRenderer; import net.combase.desktopcrm.data.CrmHelper; import net.combase.desktopcrm.domain.EmailTemplate; ((JButton) value).doClick(); } } } }); table.setDefaultRenderer(JButton.class, new TableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (value instanceof JButton) { return (JButton) value; } return new JLabel(); } }); table.getColumnModel().getColumn(1).setMaxWidth(30); table.getColumnModel().getColumn(2).setMaxWidth(30); table.setRowHeight(30); add(table.getTableHeader(), BorderLayout.NORTH); add(new JScrollPane(table), BorderLayout.CENTER); UiUtil.runAndRepeat(new Runnable() { @Override public void run() {
CrmHelper.updateEmailTemplateCache();
tfreier/desktop-crm
src/main/java/net/combase/desktopcrm/data/CrmHelper.java
// Path: src/main/java/net/combase/desktopcrm/domain/AbstractCrmObject.java // public abstract class AbstractCrmObject // { // private String id; // // private String viewUrl; // // private String editUrl; // // private String relatedObjectType; // // private String relatedObjectUrl; // // private String relatedObjectId; // // private String title; // // private String activitiesUrl; // // // /** // * @return the activitiesUrl // */ // public String getActivitiesUrl() // { // return activitiesUrl; // } // // // /** // * @param activitiesUrl the activitiesUrl to set // */ // public void setActivitiesUrl(String activitiesUrl) // { // this.activitiesUrl = activitiesUrl; // } // // // private String assignedUser; // // // public String getAssignedUser() // { // return assignedUser; // } // // // public void setAssignedUser(String assignedUser) // { // this.assignedUser = assignedUser; // } // // // public abstract String getCrmEntityType(); // // // public String getRelatedObjectId() // { // return relatedObjectId; // } // // // public void setRelatedObjectId(String relatedObjectId) // { // this.relatedObjectId = relatedObjectId; // } // // // public AbstractCrmObject() // { // super(); // } // // // public AbstractCrmObject(String id, String title) // { // super(); // this.id = id; // this.title = title; // } // // // public String getId() // { // return id; // } // // // public String getViewUrl() // { // return viewUrl; // } // // // public void setViewUrl(String viewUrl) // { // this.viewUrl = viewUrl; // } // // // public String getEditUrl() // { // return editUrl; // } // // // public void setEditUrl(String editUrl) // { // this.editUrl = editUrl; // } // // // public String getRelatedObjectType() // { // return relatedObjectType; // } // // // public void setRelatedObjectType(String relatedObjectType) // { // this.relatedObjectType = relatedObjectType; // } // // // public String getRelatedObjectUrl() // { // return relatedObjectUrl; // } // // // public void setRelatedObjectUrl(String realtedObjectUrl) // { // this.relatedObjectUrl = realtedObjectUrl; // } // // // public String getTitle() // { // return title; // } // // // public void setTitle(String title) // { // this.title = title; // } // // // @Override // public String toString() // { // return title; // } // // } // // Path: src/main/java/net/combase/desktopcrm/domain/EmailTemplate.java // public class EmailTemplate extends AbstractCrmObject { // // private String body; // private String htmlBody; // private String subject; // // public EmailTemplate(String id, String title) { // super(id, title); // } // // // public String getHtmlBody() // { // return htmlBody; // } // // // public void setHtmlBody(String htmlBody) // { // this.htmlBody = htmlBody; // } // // // public String getBody() // { // return body; // } // // public void setBody(String body) // { // this.body = body; // } // // public String getSubject() // { // return subject; // } // // public void setSubject(String subject) // { // this.subject = subject; // } // // // @Override // public String getCrmEntityType() // { // return "EmailTemplates"; // } // // // }
import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.TreeSet; import net.combase.desktopcrm.domain.AbstractCrmObject; import net.combase.desktopcrm.domain.EmailTemplate;
/** * */ package net.combase.desktopcrm.data; /** * @author "Till Freier" * */ public final class CrmHelper { private CrmHelper() { }
// Path: src/main/java/net/combase/desktopcrm/domain/AbstractCrmObject.java // public abstract class AbstractCrmObject // { // private String id; // // private String viewUrl; // // private String editUrl; // // private String relatedObjectType; // // private String relatedObjectUrl; // // private String relatedObjectId; // // private String title; // // private String activitiesUrl; // // // /** // * @return the activitiesUrl // */ // public String getActivitiesUrl() // { // return activitiesUrl; // } // // // /** // * @param activitiesUrl the activitiesUrl to set // */ // public void setActivitiesUrl(String activitiesUrl) // { // this.activitiesUrl = activitiesUrl; // } // // // private String assignedUser; // // // public String getAssignedUser() // { // return assignedUser; // } // // // public void setAssignedUser(String assignedUser) // { // this.assignedUser = assignedUser; // } // // // public abstract String getCrmEntityType(); // // // public String getRelatedObjectId() // { // return relatedObjectId; // } // // // public void setRelatedObjectId(String relatedObjectId) // { // this.relatedObjectId = relatedObjectId; // } // // // public AbstractCrmObject() // { // super(); // } // // // public AbstractCrmObject(String id, String title) // { // super(); // this.id = id; // this.title = title; // } // // // public String getId() // { // return id; // } // // // public String getViewUrl() // { // return viewUrl; // } // // // public void setViewUrl(String viewUrl) // { // this.viewUrl = viewUrl; // } // // // public String getEditUrl() // { // return editUrl; // } // // // public void setEditUrl(String editUrl) // { // this.editUrl = editUrl; // } // // // public String getRelatedObjectType() // { // return relatedObjectType; // } // // // public void setRelatedObjectType(String relatedObjectType) // { // this.relatedObjectType = relatedObjectType; // } // // // public String getRelatedObjectUrl() // { // return relatedObjectUrl; // } // // // public void setRelatedObjectUrl(String realtedObjectUrl) // { // this.relatedObjectUrl = realtedObjectUrl; // } // // // public String getTitle() // { // return title; // } // // // public void setTitle(String title) // { // this.title = title; // } // // // @Override // public String toString() // { // return title; // } // // } // // Path: src/main/java/net/combase/desktopcrm/domain/EmailTemplate.java // public class EmailTemplate extends AbstractCrmObject { // // private String body; // private String htmlBody; // private String subject; // // public EmailTemplate(String id, String title) { // super(id, title); // } // // // public String getHtmlBody() // { // return htmlBody; // } // // // public void setHtmlBody(String htmlBody) // { // this.htmlBody = htmlBody; // } // // // public String getBody() // { // return body; // } // // public void setBody(String body) // { // this.body = body; // } // // public String getSubject() // { // return subject; // } // // public void setSubject(String subject) // { // this.subject = subject; // } // // // @Override // public String getCrmEntityType() // { // return "EmailTemplates"; // } // // // } // Path: src/main/java/net/combase/desktopcrm/data/CrmHelper.java import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.TreeSet; import net.combase.desktopcrm.domain.AbstractCrmObject; import net.combase.desktopcrm.domain.EmailTemplate; /** * */ package net.combase.desktopcrm.data; /** * @author "Till Freier" * */ public final class CrmHelper { private CrmHelper() { }
private static Collection<EmailTemplate> emailTemplateCache = null;
tfreier/desktop-crm
src/main/java/net/combase/desktopcrm/data/CrmHelper.java
// Path: src/main/java/net/combase/desktopcrm/domain/AbstractCrmObject.java // public abstract class AbstractCrmObject // { // private String id; // // private String viewUrl; // // private String editUrl; // // private String relatedObjectType; // // private String relatedObjectUrl; // // private String relatedObjectId; // // private String title; // // private String activitiesUrl; // // // /** // * @return the activitiesUrl // */ // public String getActivitiesUrl() // { // return activitiesUrl; // } // // // /** // * @param activitiesUrl the activitiesUrl to set // */ // public void setActivitiesUrl(String activitiesUrl) // { // this.activitiesUrl = activitiesUrl; // } // // // private String assignedUser; // // // public String getAssignedUser() // { // return assignedUser; // } // // // public void setAssignedUser(String assignedUser) // { // this.assignedUser = assignedUser; // } // // // public abstract String getCrmEntityType(); // // // public String getRelatedObjectId() // { // return relatedObjectId; // } // // // public void setRelatedObjectId(String relatedObjectId) // { // this.relatedObjectId = relatedObjectId; // } // // // public AbstractCrmObject() // { // super(); // } // // // public AbstractCrmObject(String id, String title) // { // super(); // this.id = id; // this.title = title; // } // // // public String getId() // { // return id; // } // // // public String getViewUrl() // { // return viewUrl; // } // // // public void setViewUrl(String viewUrl) // { // this.viewUrl = viewUrl; // } // // // public String getEditUrl() // { // return editUrl; // } // // // public void setEditUrl(String editUrl) // { // this.editUrl = editUrl; // } // // // public String getRelatedObjectType() // { // return relatedObjectType; // } // // // public void setRelatedObjectType(String relatedObjectType) // { // this.relatedObjectType = relatedObjectType; // } // // // public String getRelatedObjectUrl() // { // return relatedObjectUrl; // } // // // public void setRelatedObjectUrl(String realtedObjectUrl) // { // this.relatedObjectUrl = realtedObjectUrl; // } // // // public String getTitle() // { // return title; // } // // // public void setTitle(String title) // { // this.title = title; // } // // // @Override // public String toString() // { // return title; // } // // } // // Path: src/main/java/net/combase/desktopcrm/domain/EmailTemplate.java // public class EmailTemplate extends AbstractCrmObject { // // private String body; // private String htmlBody; // private String subject; // // public EmailTemplate(String id, String title) { // super(id, title); // } // // // public String getHtmlBody() // { // return htmlBody; // } // // // public void setHtmlBody(String htmlBody) // { // this.htmlBody = htmlBody; // } // // // public String getBody() // { // return body; // } // // public void setBody(String body) // { // this.body = body; // } // // public String getSubject() // { // return subject; // } // // public void setSubject(String subject) // { // this.subject = subject; // } // // // @Override // public String getCrmEntityType() // { // return "EmailTemplates"; // } // // // }
import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.TreeSet; import net.combase.desktopcrm.domain.AbstractCrmObject; import net.combase.desktopcrm.domain.EmailTemplate;
/** * */ package net.combase.desktopcrm.data; /** * @author "Till Freier" * */ public final class CrmHelper { private CrmHelper() { } private static Collection<EmailTemplate> emailTemplateCache = null; public static synchronized void updateEmailTemplateCache() { emailTemplateCache = new TreeSet<>(new Comparator<EmailTemplate>() { @Override public int compare(EmailTemplate o1, EmailTemplate o2) { return o1.getTitle().compareTo(o2.getTitle()); } }); emailTemplateCache.addAll(CrmManager.getEmailTemplateList()); } public static synchronized Collection<EmailTemplate> getCachedEmailTemplates() { if (emailTemplateCache == null) { updateEmailTemplateCache(); } return emailTemplateCache; }
// Path: src/main/java/net/combase/desktopcrm/domain/AbstractCrmObject.java // public abstract class AbstractCrmObject // { // private String id; // // private String viewUrl; // // private String editUrl; // // private String relatedObjectType; // // private String relatedObjectUrl; // // private String relatedObjectId; // // private String title; // // private String activitiesUrl; // // // /** // * @return the activitiesUrl // */ // public String getActivitiesUrl() // { // return activitiesUrl; // } // // // /** // * @param activitiesUrl the activitiesUrl to set // */ // public void setActivitiesUrl(String activitiesUrl) // { // this.activitiesUrl = activitiesUrl; // } // // // private String assignedUser; // // // public String getAssignedUser() // { // return assignedUser; // } // // // public void setAssignedUser(String assignedUser) // { // this.assignedUser = assignedUser; // } // // // public abstract String getCrmEntityType(); // // // public String getRelatedObjectId() // { // return relatedObjectId; // } // // // public void setRelatedObjectId(String relatedObjectId) // { // this.relatedObjectId = relatedObjectId; // } // // // public AbstractCrmObject() // { // super(); // } // // // public AbstractCrmObject(String id, String title) // { // super(); // this.id = id; // this.title = title; // } // // // public String getId() // { // return id; // } // // // public String getViewUrl() // { // return viewUrl; // } // // // public void setViewUrl(String viewUrl) // { // this.viewUrl = viewUrl; // } // // // public String getEditUrl() // { // return editUrl; // } // // // public void setEditUrl(String editUrl) // { // this.editUrl = editUrl; // } // // // public String getRelatedObjectType() // { // return relatedObjectType; // } // // // public void setRelatedObjectType(String relatedObjectType) // { // this.relatedObjectType = relatedObjectType; // } // // // public String getRelatedObjectUrl() // { // return relatedObjectUrl; // } // // // public void setRelatedObjectUrl(String realtedObjectUrl) // { // this.relatedObjectUrl = realtedObjectUrl; // } // // // public String getTitle() // { // return title; // } // // // public void setTitle(String title) // { // this.title = title; // } // // // @Override // public String toString() // { // return title; // } // // } // // Path: src/main/java/net/combase/desktopcrm/domain/EmailTemplate.java // public class EmailTemplate extends AbstractCrmObject { // // private String body; // private String htmlBody; // private String subject; // // public EmailTemplate(String id, String title) { // super(id, title); // } // // // public String getHtmlBody() // { // return htmlBody; // } // // // public void setHtmlBody(String htmlBody) // { // this.htmlBody = htmlBody; // } // // // public String getBody() // { // return body; // } // // public void setBody(String body) // { // this.body = body; // } // // public String getSubject() // { // return subject; // } // // public void setSubject(String subject) // { // this.subject = subject; // } // // // @Override // public String getCrmEntityType() // { // return "EmailTemplates"; // } // // // } // Path: src/main/java/net/combase/desktopcrm/data/CrmHelper.java import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.TreeSet; import net.combase.desktopcrm.domain.AbstractCrmObject; import net.combase.desktopcrm.domain.EmailTemplate; /** * */ package net.combase.desktopcrm.data; /** * @author "Till Freier" * */ public final class CrmHelper { private CrmHelper() { } private static Collection<EmailTemplate> emailTemplateCache = null; public static synchronized void updateEmailTemplateCache() { emailTemplateCache = new TreeSet<>(new Comparator<EmailTemplate>() { @Override public int compare(EmailTemplate o1, EmailTemplate o2) { return o1.getTitle().compareTo(o2.getTitle()); } }); emailTemplateCache.addAll(CrmManager.getEmailTemplateList()); } public static synchronized Collection<EmailTemplate> getCachedEmailTemplates() { if (emailTemplateCache == null) { updateEmailTemplateCache(); } return emailTemplateCache; }
public static List<AbstractCrmObject> getActionObjects()
tfreier/desktop-crm
src/main/java/net/combase/desktopcrm/data/DataStoreManager.java
// Path: src/main/java/net/combase/desktopcrm/domain/DataStore.java // @XmlRootElement // public class DataStore { // private Settings settings = new Settings(); // // public Settings getSettings() { // return settings; // } // // public void setSettings(Settings settings) { // this.settings = settings; // } // // // } // // Path: src/main/java/net/combase/desktopcrm/domain/Settings.java // public class Settings implements Serializable // { // /** // * // */ // private static final long serialVersionUID = -2756760963012353808L; // private String crmUrl; // private String user; // private String password; // private int gmtOffset = 0; // private String accountCriteria; // private String asteriskHost; // private String asteriskUser; // private String asteriskPassword; // private String asteriskExtension; // // private String dialUrl; // // private boolean callReminder = true; // private boolean meetingReminder = true; // private boolean taskReminder = true; // private boolean leadReminder = true; // private boolean opportunityReminder = true; // private boolean caseReminder = true; // // public boolean isMeetingReminder() // { // return meetingReminder; // } // // public void setMeetingReminder(boolean meetingReminder) // { // this.meetingReminder = meetingReminder; // } // // public String getDialUrl() // { // return dialUrl; // } // // public void setDialUrl(String dialUrl) // { // this.dialUrl = dialUrl; // } // // public String getAsteriskHost() // { // return asteriskHost; // } // // public void setAsteriskHost(String asteriskHost) // { // this.asteriskHost = asteriskHost; // } // // public String getAsteriskUser() // { // return asteriskUser; // } // // public void setAsteriskUser(String asteriskUser) // { // this.asteriskUser = asteriskUser; // } // // public String getAsteriskPassword() // { // return asteriskPassword; // } // // public void setAsteriskPassword(String asteriskPassword) // { // this.asteriskPassword = asteriskPassword; // } // // public String getAsteriskExtension() // { // return asteriskExtension; // } // // public void setAsteriskExtension(String asteriskExtension) // { // this.asteriskExtension = asteriskExtension; // } // // public boolean isCallReminder() // { // return callReminder; // } // // public void setCallReminder(boolean callReminder) // { // this.callReminder = callReminder; // } // // public boolean isTaskReminder() // { // return taskReminder; // } // // public void setTaskReminder(boolean taskReminder) // { // this.taskReminder = taskReminder; // } // // public boolean isLeadReminder() // { // return leadReminder; // } // // public void setLeadReminder(boolean leadReminder) // { // this.leadReminder = leadReminder; // } // // public boolean isOpportunityReminder() // { // return opportunityReminder; // } // // public void setOpportunityReminder(boolean opportunityReminder) // { // this.opportunityReminder = opportunityReminder; // } // // public boolean isCaseReminder() // { // return caseReminder; // } // // public void setCaseReminder(boolean caseReminder) // { // this.caseReminder = caseReminder; // } // // public String getAccountCriteria() // { // return accountCriteria; // } // // public void setAccountCriteria(String accountCriteria) // { // this.accountCriteria = accountCriteria; // } // // public int getGmtOffset() // { // return gmtOffset; // } // // public void setGmtOffset(int gmtOffset) // { // this.gmtOffset = gmtOffset; // } // // public String getCrmUrl() // { // return crmUrl; // } // // public void setCrmUrl(String crmUrl) // { // this.crmUrl = crmUrl; // } // // public String getUser() // { // return user; // } // // public void setUser(String user) // { // this.user = user; // } // // public String getPassword() // { // return password; // } // // public void setPassword(String password) // { // this.password = password; // } // // }
import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import net.combase.desktopcrm.domain.DataStore; import net.combase.desktopcrm.domain.Settings;
/** * */ package net.combase.desktopcrm.data; /** * @author till * */ public class DataStoreManager { private static Settings settings;
// Path: src/main/java/net/combase/desktopcrm/domain/DataStore.java // @XmlRootElement // public class DataStore { // private Settings settings = new Settings(); // // public Settings getSettings() { // return settings; // } // // public void setSettings(Settings settings) { // this.settings = settings; // } // // // } // // Path: src/main/java/net/combase/desktopcrm/domain/Settings.java // public class Settings implements Serializable // { // /** // * // */ // private static final long serialVersionUID = -2756760963012353808L; // private String crmUrl; // private String user; // private String password; // private int gmtOffset = 0; // private String accountCriteria; // private String asteriskHost; // private String asteriskUser; // private String asteriskPassword; // private String asteriskExtension; // // private String dialUrl; // // private boolean callReminder = true; // private boolean meetingReminder = true; // private boolean taskReminder = true; // private boolean leadReminder = true; // private boolean opportunityReminder = true; // private boolean caseReminder = true; // // public boolean isMeetingReminder() // { // return meetingReminder; // } // // public void setMeetingReminder(boolean meetingReminder) // { // this.meetingReminder = meetingReminder; // } // // public String getDialUrl() // { // return dialUrl; // } // // public void setDialUrl(String dialUrl) // { // this.dialUrl = dialUrl; // } // // public String getAsteriskHost() // { // return asteriskHost; // } // // public void setAsteriskHost(String asteriskHost) // { // this.asteriskHost = asteriskHost; // } // // public String getAsteriskUser() // { // return asteriskUser; // } // // public void setAsteriskUser(String asteriskUser) // { // this.asteriskUser = asteriskUser; // } // // public String getAsteriskPassword() // { // return asteriskPassword; // } // // public void setAsteriskPassword(String asteriskPassword) // { // this.asteriskPassword = asteriskPassword; // } // // public String getAsteriskExtension() // { // return asteriskExtension; // } // // public void setAsteriskExtension(String asteriskExtension) // { // this.asteriskExtension = asteriskExtension; // } // // public boolean isCallReminder() // { // return callReminder; // } // // public void setCallReminder(boolean callReminder) // { // this.callReminder = callReminder; // } // // public boolean isTaskReminder() // { // return taskReminder; // } // // public void setTaskReminder(boolean taskReminder) // { // this.taskReminder = taskReminder; // } // // public boolean isLeadReminder() // { // return leadReminder; // } // // public void setLeadReminder(boolean leadReminder) // { // this.leadReminder = leadReminder; // } // // public boolean isOpportunityReminder() // { // return opportunityReminder; // } // // public void setOpportunityReminder(boolean opportunityReminder) // { // this.opportunityReminder = opportunityReminder; // } // // public boolean isCaseReminder() // { // return caseReminder; // } // // public void setCaseReminder(boolean caseReminder) // { // this.caseReminder = caseReminder; // } // // public String getAccountCriteria() // { // return accountCriteria; // } // // public void setAccountCriteria(String accountCriteria) // { // this.accountCriteria = accountCriteria; // } // // public int getGmtOffset() // { // return gmtOffset; // } // // public void setGmtOffset(int gmtOffset) // { // this.gmtOffset = gmtOffset; // } // // public String getCrmUrl() // { // return crmUrl; // } // // public void setCrmUrl(String crmUrl) // { // this.crmUrl = crmUrl; // } // // public String getUser() // { // return user; // } // // public void setUser(String user) // { // this.user = user; // } // // public String getPassword() // { // return password; // } // // public void setPassword(String password) // { // this.password = password; // } // // } // Path: src/main/java/net/combase/desktopcrm/data/DataStoreManager.java import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import net.combase.desktopcrm.domain.DataStore; import net.combase.desktopcrm.domain.Settings; /** * */ package net.combase.desktopcrm.data; /** * @author till * */ public class DataStoreManager { private static Settings settings;
private static DataStore load() throws JAXBException, FileNotFoundException
tfreier/desktop-crm
src/main/java/com/sugarcrm/api/v4/impl/SugarApi.java
// Path: src/main/java/com/sugarcrm/api/SugarApiException.java // public class SugarApiException extends Exception { // // private static final long serialVersionUID = 1L; // // protected int number = 0; // protected String description = ""; // // public SugarApiException(String message){ // super(message); // } // // public SugarApiException(String message, Throwable rootCause){ // super(message, rootCause); // } // // public void setNumber(int number) { // this.number = number; // } // // public void setDescription(String description) { // this.description = description; // } // // /** // * Error identifying number returned from server // * Zero value indicates a wrapped exception meaning you should check {@link Exception#getCause()} for more details. // * @return error number // */ // public int getNumber() { // return number; // } // // public String getDescription() { // return description; // } // // } // // Path: src/main/java/com/sugarcrm/api/SugarCredentials.java // public class SugarCredentials { // // private String user_name; // private String password; // // public SugarCredentials() throws SugarApiException{ // this(null, null); // } // // public SugarCredentials(String userId, String plaintextPassword) throws SugarApiException{ // this.user_name = userId; // if(plaintextPassword != null){ // setPassword(plaintextPassword); // } // } // // public void setPassword(String plaintextPassword) throws SugarApiException{ // try { // this.password = Hex.encodeHexString(MessageDigest.getInstance("MD5").digest(plaintextPassword.getBytes())); // }catch(NoSuchAlgorithmException ex){ // SugarApiException sae = new SugarApiException("Unable to generate Sugar password value because this JRE does not support MD5", ex); // throw sae; // } // } // // public String getUserName(){ // return user_name; // } // // public String getEncodedPassword(){ // return password; // } // // // } // // Path: src/main/java/com/sugarcrm/api/SugarEntity.java // public interface SugarEntity // { // String get(String fieldName); // // ArrayList<HashMap<String, String>> getData(); // // Collection<String> getFieldNames(); // // String getId(); // // String getModuleName(); // // String set(String fieldName, String value); // } // // Path: src/main/java/com/sugarcrm/api/SugarSession.java // public interface SugarSession { // // public String getSessionID(); // public User getUser(); // // }
import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.net.URLCodec; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import com.sugarcrm.api.SugarApiException; import com.sugarcrm.api.SugarCredentials; import com.sugarcrm.api.SugarEntity; import com.sugarcrm.api.SugarSession;
return this.session; } public void setLinkFieldName(final String linkFieldName) { this.linkFieldName = linkFieldName; } public void setModuleId(final String moduleId) { this.moduleId = moduleId; } public void setModuleName(final String moduleName) { this.moduleName = moduleName; } public void setSession(final String session) { this.session = session; } } public class SugarLoginRequest {
// Path: src/main/java/com/sugarcrm/api/SugarApiException.java // public class SugarApiException extends Exception { // // private static final long serialVersionUID = 1L; // // protected int number = 0; // protected String description = ""; // // public SugarApiException(String message){ // super(message); // } // // public SugarApiException(String message, Throwable rootCause){ // super(message, rootCause); // } // // public void setNumber(int number) { // this.number = number; // } // // public void setDescription(String description) { // this.description = description; // } // // /** // * Error identifying number returned from server // * Zero value indicates a wrapped exception meaning you should check {@link Exception#getCause()} for more details. // * @return error number // */ // public int getNumber() { // return number; // } // // public String getDescription() { // return description; // } // // } // // Path: src/main/java/com/sugarcrm/api/SugarCredentials.java // public class SugarCredentials { // // private String user_name; // private String password; // // public SugarCredentials() throws SugarApiException{ // this(null, null); // } // // public SugarCredentials(String userId, String plaintextPassword) throws SugarApiException{ // this.user_name = userId; // if(plaintextPassword != null){ // setPassword(plaintextPassword); // } // } // // public void setPassword(String plaintextPassword) throws SugarApiException{ // try { // this.password = Hex.encodeHexString(MessageDigest.getInstance("MD5").digest(plaintextPassword.getBytes())); // }catch(NoSuchAlgorithmException ex){ // SugarApiException sae = new SugarApiException("Unable to generate Sugar password value because this JRE does not support MD5", ex); // throw sae; // } // } // // public String getUserName(){ // return user_name; // } // // public String getEncodedPassword(){ // return password; // } // // // } // // Path: src/main/java/com/sugarcrm/api/SugarEntity.java // public interface SugarEntity // { // String get(String fieldName); // // ArrayList<HashMap<String, String>> getData(); // // Collection<String> getFieldNames(); // // String getId(); // // String getModuleName(); // // String set(String fieldName, String value); // } // // Path: src/main/java/com/sugarcrm/api/SugarSession.java // public interface SugarSession { // // public String getSessionID(); // public User getUser(); // // } // Path: src/main/java/com/sugarcrm/api/v4/impl/SugarApi.java import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.net.URLCodec; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import com.sugarcrm.api.SugarApiException; import com.sugarcrm.api.SugarCredentials; import com.sugarcrm.api.SugarEntity; import com.sugarcrm.api.SugarSession; return this.session; } public void setLinkFieldName(final String linkFieldName) { this.linkFieldName = linkFieldName; } public void setModuleId(final String moduleId) { this.moduleId = moduleId; } public void setModuleName(final String moduleName) { this.moduleName = moduleName; } public void setSession(final String session) { this.session = session; } } public class SugarLoginRequest {
protected SugarCredentials user_auth;
tfreier/desktop-crm
src/main/java/com/sugarcrm/api/v4/impl/SugarApi.java
// Path: src/main/java/com/sugarcrm/api/SugarApiException.java // public class SugarApiException extends Exception { // // private static final long serialVersionUID = 1L; // // protected int number = 0; // protected String description = ""; // // public SugarApiException(String message){ // super(message); // } // // public SugarApiException(String message, Throwable rootCause){ // super(message, rootCause); // } // // public void setNumber(int number) { // this.number = number; // } // // public void setDescription(String description) { // this.description = description; // } // // /** // * Error identifying number returned from server // * Zero value indicates a wrapped exception meaning you should check {@link Exception#getCause()} for more details. // * @return error number // */ // public int getNumber() { // return number; // } // // public String getDescription() { // return description; // } // // } // // Path: src/main/java/com/sugarcrm/api/SugarCredentials.java // public class SugarCredentials { // // private String user_name; // private String password; // // public SugarCredentials() throws SugarApiException{ // this(null, null); // } // // public SugarCredentials(String userId, String plaintextPassword) throws SugarApiException{ // this.user_name = userId; // if(plaintextPassword != null){ // setPassword(plaintextPassword); // } // } // // public void setPassword(String plaintextPassword) throws SugarApiException{ // try { // this.password = Hex.encodeHexString(MessageDigest.getInstance("MD5").digest(plaintextPassword.getBytes())); // }catch(NoSuchAlgorithmException ex){ // SugarApiException sae = new SugarApiException("Unable to generate Sugar password value because this JRE does not support MD5", ex); // throw sae; // } // } // // public String getUserName(){ // return user_name; // } // // public String getEncodedPassword(){ // return password; // } // // // } // // Path: src/main/java/com/sugarcrm/api/SugarEntity.java // public interface SugarEntity // { // String get(String fieldName); // // ArrayList<HashMap<String, String>> getData(); // // Collection<String> getFieldNames(); // // String getId(); // // String getModuleName(); // // String set(String fieldName, String value); // } // // Path: src/main/java/com/sugarcrm/api/SugarSession.java // public interface SugarSession { // // public String getSessionID(); // public User getUser(); // // }
import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.net.URLCodec; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import com.sugarcrm.api.SugarApiException; import com.sugarcrm.api.SugarCredentials; import com.sugarcrm.api.SugarEntity; import com.sugarcrm.api.SugarSession;
} } public class SugarLoginRequest { protected SugarCredentials user_auth; public void setUserAuth(final SugarCredentials auth) { this.user_auth = auth; } } private String REST_ENDPOINT = null; private URLCodec codec = null; private Gson json = null; public SugarApi(final String sugarUrl) { this.REST_ENDPOINT = sugarUrl + "/service/v4_1/rest.php"; this.json = new GsonBuilder().create(); this.codec = new URLCodec(); }
// Path: src/main/java/com/sugarcrm/api/SugarApiException.java // public class SugarApiException extends Exception { // // private static final long serialVersionUID = 1L; // // protected int number = 0; // protected String description = ""; // // public SugarApiException(String message){ // super(message); // } // // public SugarApiException(String message, Throwable rootCause){ // super(message, rootCause); // } // // public void setNumber(int number) { // this.number = number; // } // // public void setDescription(String description) { // this.description = description; // } // // /** // * Error identifying number returned from server // * Zero value indicates a wrapped exception meaning you should check {@link Exception#getCause()} for more details. // * @return error number // */ // public int getNumber() { // return number; // } // // public String getDescription() { // return description; // } // // } // // Path: src/main/java/com/sugarcrm/api/SugarCredentials.java // public class SugarCredentials { // // private String user_name; // private String password; // // public SugarCredentials() throws SugarApiException{ // this(null, null); // } // // public SugarCredentials(String userId, String plaintextPassword) throws SugarApiException{ // this.user_name = userId; // if(plaintextPassword != null){ // setPassword(plaintextPassword); // } // } // // public void setPassword(String plaintextPassword) throws SugarApiException{ // try { // this.password = Hex.encodeHexString(MessageDigest.getInstance("MD5").digest(plaintextPassword.getBytes())); // }catch(NoSuchAlgorithmException ex){ // SugarApiException sae = new SugarApiException("Unable to generate Sugar password value because this JRE does not support MD5", ex); // throw sae; // } // } // // public String getUserName(){ // return user_name; // } // // public String getEncodedPassword(){ // return password; // } // // // } // // Path: src/main/java/com/sugarcrm/api/SugarEntity.java // public interface SugarEntity // { // String get(String fieldName); // // ArrayList<HashMap<String, String>> getData(); // // Collection<String> getFieldNames(); // // String getId(); // // String getModuleName(); // // String set(String fieldName, String value); // } // // Path: src/main/java/com/sugarcrm/api/SugarSession.java // public interface SugarSession { // // public String getSessionID(); // public User getUser(); // // } // Path: src/main/java/com/sugarcrm/api/v4/impl/SugarApi.java import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.net.URLCodec; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import com.sugarcrm.api.SugarApiException; import com.sugarcrm.api.SugarCredentials; import com.sugarcrm.api.SugarEntity; import com.sugarcrm.api.SugarSession; } } public class SugarLoginRequest { protected SugarCredentials user_auth; public void setUserAuth(final SugarCredentials auth) { this.user_auth = auth; } } private String REST_ENDPOINT = null; private URLCodec codec = null; private Gson json = null; public SugarApi(final String sugarUrl) { this.REST_ENDPOINT = sugarUrl + "/service/v4_1/rest.php"; this.json = new GsonBuilder().create(); this.codec = new URLCodec(); }
public SugarEntity getBean(final SugarSession session, final String moduleName, final String guid) throws SugarApiException
tfreier/desktop-crm
src/main/java/com/sugarcrm/api/v4/impl/SugarApi.java
// Path: src/main/java/com/sugarcrm/api/SugarApiException.java // public class SugarApiException extends Exception { // // private static final long serialVersionUID = 1L; // // protected int number = 0; // protected String description = ""; // // public SugarApiException(String message){ // super(message); // } // // public SugarApiException(String message, Throwable rootCause){ // super(message, rootCause); // } // // public void setNumber(int number) { // this.number = number; // } // // public void setDescription(String description) { // this.description = description; // } // // /** // * Error identifying number returned from server // * Zero value indicates a wrapped exception meaning you should check {@link Exception#getCause()} for more details. // * @return error number // */ // public int getNumber() { // return number; // } // // public String getDescription() { // return description; // } // // } // // Path: src/main/java/com/sugarcrm/api/SugarCredentials.java // public class SugarCredentials { // // private String user_name; // private String password; // // public SugarCredentials() throws SugarApiException{ // this(null, null); // } // // public SugarCredentials(String userId, String plaintextPassword) throws SugarApiException{ // this.user_name = userId; // if(plaintextPassword != null){ // setPassword(plaintextPassword); // } // } // // public void setPassword(String plaintextPassword) throws SugarApiException{ // try { // this.password = Hex.encodeHexString(MessageDigest.getInstance("MD5").digest(plaintextPassword.getBytes())); // }catch(NoSuchAlgorithmException ex){ // SugarApiException sae = new SugarApiException("Unable to generate Sugar password value because this JRE does not support MD5", ex); // throw sae; // } // } // // public String getUserName(){ // return user_name; // } // // public String getEncodedPassword(){ // return password; // } // // // } // // Path: src/main/java/com/sugarcrm/api/SugarEntity.java // public interface SugarEntity // { // String get(String fieldName); // // ArrayList<HashMap<String, String>> getData(); // // Collection<String> getFieldNames(); // // String getId(); // // String getModuleName(); // // String set(String fieldName, String value); // } // // Path: src/main/java/com/sugarcrm/api/SugarSession.java // public interface SugarSession { // // public String getSessionID(); // public User getUser(); // // }
import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.net.URLCodec; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import com.sugarcrm.api.SugarApiException; import com.sugarcrm.api.SugarCredentials; import com.sugarcrm.api.SugarEntity; import com.sugarcrm.api.SugarSession;
} } public class SugarLoginRequest { protected SugarCredentials user_auth; public void setUserAuth(final SugarCredentials auth) { this.user_auth = auth; } } private String REST_ENDPOINT = null; private URLCodec codec = null; private Gson json = null; public SugarApi(final String sugarUrl) { this.REST_ENDPOINT = sugarUrl + "/service/v4_1/rest.php"; this.json = new GsonBuilder().create(); this.codec = new URLCodec(); }
// Path: src/main/java/com/sugarcrm/api/SugarApiException.java // public class SugarApiException extends Exception { // // private static final long serialVersionUID = 1L; // // protected int number = 0; // protected String description = ""; // // public SugarApiException(String message){ // super(message); // } // // public SugarApiException(String message, Throwable rootCause){ // super(message, rootCause); // } // // public void setNumber(int number) { // this.number = number; // } // // public void setDescription(String description) { // this.description = description; // } // // /** // * Error identifying number returned from server // * Zero value indicates a wrapped exception meaning you should check {@link Exception#getCause()} for more details. // * @return error number // */ // public int getNumber() { // return number; // } // // public String getDescription() { // return description; // } // // } // // Path: src/main/java/com/sugarcrm/api/SugarCredentials.java // public class SugarCredentials { // // private String user_name; // private String password; // // public SugarCredentials() throws SugarApiException{ // this(null, null); // } // // public SugarCredentials(String userId, String plaintextPassword) throws SugarApiException{ // this.user_name = userId; // if(plaintextPassword != null){ // setPassword(plaintextPassword); // } // } // // public void setPassword(String plaintextPassword) throws SugarApiException{ // try { // this.password = Hex.encodeHexString(MessageDigest.getInstance("MD5").digest(plaintextPassword.getBytes())); // }catch(NoSuchAlgorithmException ex){ // SugarApiException sae = new SugarApiException("Unable to generate Sugar password value because this JRE does not support MD5", ex); // throw sae; // } // } // // public String getUserName(){ // return user_name; // } // // public String getEncodedPassword(){ // return password; // } // // // } // // Path: src/main/java/com/sugarcrm/api/SugarEntity.java // public interface SugarEntity // { // String get(String fieldName); // // ArrayList<HashMap<String, String>> getData(); // // Collection<String> getFieldNames(); // // String getId(); // // String getModuleName(); // // String set(String fieldName, String value); // } // // Path: src/main/java/com/sugarcrm/api/SugarSession.java // public interface SugarSession { // // public String getSessionID(); // public User getUser(); // // } // Path: src/main/java/com/sugarcrm/api/v4/impl/SugarApi.java import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.net.URLCodec; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import com.sugarcrm.api.SugarApiException; import com.sugarcrm.api.SugarCredentials; import com.sugarcrm.api.SugarEntity; import com.sugarcrm.api.SugarSession; } } public class SugarLoginRequest { protected SugarCredentials user_auth; public void setUserAuth(final SugarCredentials auth) { this.user_auth = auth; } } private String REST_ENDPOINT = null; private URLCodec codec = null; private Gson json = null; public SugarApi(final String sugarUrl) { this.REST_ENDPOINT = sugarUrl + "/service/v4_1/rest.php"; this.json = new GsonBuilder().create(); this.codec = new URLCodec(); }
public SugarEntity getBean(final SugarSession session, final String moduleName, final String guid) throws SugarApiException
tfreier/desktop-crm
src/main/java/com/sugarcrm/api/v4/impl/SugarApi.java
// Path: src/main/java/com/sugarcrm/api/SugarApiException.java // public class SugarApiException extends Exception { // // private static final long serialVersionUID = 1L; // // protected int number = 0; // protected String description = ""; // // public SugarApiException(String message){ // super(message); // } // // public SugarApiException(String message, Throwable rootCause){ // super(message, rootCause); // } // // public void setNumber(int number) { // this.number = number; // } // // public void setDescription(String description) { // this.description = description; // } // // /** // * Error identifying number returned from server // * Zero value indicates a wrapped exception meaning you should check {@link Exception#getCause()} for more details. // * @return error number // */ // public int getNumber() { // return number; // } // // public String getDescription() { // return description; // } // // } // // Path: src/main/java/com/sugarcrm/api/SugarCredentials.java // public class SugarCredentials { // // private String user_name; // private String password; // // public SugarCredentials() throws SugarApiException{ // this(null, null); // } // // public SugarCredentials(String userId, String plaintextPassword) throws SugarApiException{ // this.user_name = userId; // if(plaintextPassword != null){ // setPassword(plaintextPassword); // } // } // // public void setPassword(String plaintextPassword) throws SugarApiException{ // try { // this.password = Hex.encodeHexString(MessageDigest.getInstance("MD5").digest(plaintextPassword.getBytes())); // }catch(NoSuchAlgorithmException ex){ // SugarApiException sae = new SugarApiException("Unable to generate Sugar password value because this JRE does not support MD5", ex); // throw sae; // } // } // // public String getUserName(){ // return user_name; // } // // public String getEncodedPassword(){ // return password; // } // // // } // // Path: src/main/java/com/sugarcrm/api/SugarEntity.java // public interface SugarEntity // { // String get(String fieldName); // // ArrayList<HashMap<String, String>> getData(); // // Collection<String> getFieldNames(); // // String getId(); // // String getModuleName(); // // String set(String fieldName, String value); // } // // Path: src/main/java/com/sugarcrm/api/SugarSession.java // public interface SugarSession { // // public String getSessionID(); // public User getUser(); // // }
import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.net.URLCodec; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import com.sugarcrm.api.SugarApiException; import com.sugarcrm.api.SugarCredentials; import com.sugarcrm.api.SugarEntity; import com.sugarcrm.api.SugarSession;
} } public class SugarLoginRequest { protected SugarCredentials user_auth; public void setUserAuth(final SugarCredentials auth) { this.user_auth = auth; } } private String REST_ENDPOINT = null; private URLCodec codec = null; private Gson json = null; public SugarApi(final String sugarUrl) { this.REST_ENDPOINT = sugarUrl + "/service/v4_1/rest.php"; this.json = new GsonBuilder().create(); this.codec = new URLCodec(); }
// Path: src/main/java/com/sugarcrm/api/SugarApiException.java // public class SugarApiException extends Exception { // // private static final long serialVersionUID = 1L; // // protected int number = 0; // protected String description = ""; // // public SugarApiException(String message){ // super(message); // } // // public SugarApiException(String message, Throwable rootCause){ // super(message, rootCause); // } // // public void setNumber(int number) { // this.number = number; // } // // public void setDescription(String description) { // this.description = description; // } // // /** // * Error identifying number returned from server // * Zero value indicates a wrapped exception meaning you should check {@link Exception#getCause()} for more details. // * @return error number // */ // public int getNumber() { // return number; // } // // public String getDescription() { // return description; // } // // } // // Path: src/main/java/com/sugarcrm/api/SugarCredentials.java // public class SugarCredentials { // // private String user_name; // private String password; // // public SugarCredentials() throws SugarApiException{ // this(null, null); // } // // public SugarCredentials(String userId, String plaintextPassword) throws SugarApiException{ // this.user_name = userId; // if(plaintextPassword != null){ // setPassword(plaintextPassword); // } // } // // public void setPassword(String plaintextPassword) throws SugarApiException{ // try { // this.password = Hex.encodeHexString(MessageDigest.getInstance("MD5").digest(plaintextPassword.getBytes())); // }catch(NoSuchAlgorithmException ex){ // SugarApiException sae = new SugarApiException("Unable to generate Sugar password value because this JRE does not support MD5", ex); // throw sae; // } // } // // public String getUserName(){ // return user_name; // } // // public String getEncodedPassword(){ // return password; // } // // // } // // Path: src/main/java/com/sugarcrm/api/SugarEntity.java // public interface SugarEntity // { // String get(String fieldName); // // ArrayList<HashMap<String, String>> getData(); // // Collection<String> getFieldNames(); // // String getId(); // // String getModuleName(); // // String set(String fieldName, String value); // } // // Path: src/main/java/com/sugarcrm/api/SugarSession.java // public interface SugarSession { // // public String getSessionID(); // public User getUser(); // // } // Path: src/main/java/com/sugarcrm/api/v4/impl/SugarApi.java import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import org.apache.commons.codec.EncoderException; import org.apache.commons.codec.net.URLCodec; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import com.sugarcrm.api.SugarApiException; import com.sugarcrm.api.SugarCredentials; import com.sugarcrm.api.SugarEntity; import com.sugarcrm.api.SugarSession; } } public class SugarLoginRequest { protected SugarCredentials user_auth; public void setUserAuth(final SugarCredentials auth) { this.user_auth = auth; } } private String REST_ENDPOINT = null; private URLCodec codec = null; private Gson json = null; public SugarApi(final String sugarUrl) { this.REST_ENDPOINT = sugarUrl + "/service/v4_1/rest.php"; this.json = new GsonBuilder().create(); this.codec = new URLCodec(); }
public SugarEntity getBean(final SugarSession session, final String moduleName, final String guid) throws SugarApiException
tfreier/desktop-crm
src/main/java/com/sugarcrm/api/v4/impl/SugarLoginResponse.java
// Path: src/main/java/com/sugarcrm/api/SugarSession.java // public interface SugarSession { // // public String getSessionID(); // public User getUser(); // // } // // Path: src/main/java/com/sugarcrm/api/User.java // public interface User extends SugarEntity { // // public String getUserId(); // public String getUserName(); // public String getUserLanguage(); // // }
import com.sugarcrm.api.SugarSession; import com.sugarcrm.api.User;
package com.sugarcrm.api.v4.impl; /** * Sugar login API response in v4 * @author mmarum */ public class SugarLoginResponse extends SugarBean implements SugarSession { /** * */ private static final long serialVersionUID = -1676345351737529385L; @Override public String getSessionID() { return this.id; } @Override
// Path: src/main/java/com/sugarcrm/api/SugarSession.java // public interface SugarSession { // // public String getSessionID(); // public User getUser(); // // } // // Path: src/main/java/com/sugarcrm/api/User.java // public interface User extends SugarEntity { // // public String getUserId(); // public String getUserName(); // public String getUserLanguage(); // // } // Path: src/main/java/com/sugarcrm/api/v4/impl/SugarLoginResponse.java import com.sugarcrm.api.SugarSession; import com.sugarcrm.api.User; package com.sugarcrm.api.v4.impl; /** * Sugar login API response in v4 * @author mmarum */ public class SugarLoginResponse extends SugarBean implements SugarSession { /** * */ private static final long serialVersionUID = -1676345351737529385L; @Override public String getSessionID() { return this.id; } @Override
public User getUser()
tfreier/desktop-crm
src/main/java/net/combase/desktopcrm/swing/ActionRequiredTableModel.java
// Path: src/main/java/net/combase/desktopcrm/domain/AbstractCrmObject.java // public abstract class AbstractCrmObject // { // private String id; // // private String viewUrl; // // private String editUrl; // // private String relatedObjectType; // // private String relatedObjectUrl; // // private String relatedObjectId; // // private String title; // // private String activitiesUrl; // // // /** // * @return the activitiesUrl // */ // public String getActivitiesUrl() // { // return activitiesUrl; // } // // // /** // * @param activitiesUrl the activitiesUrl to set // */ // public void setActivitiesUrl(String activitiesUrl) // { // this.activitiesUrl = activitiesUrl; // } // // // private String assignedUser; // // // public String getAssignedUser() // { // return assignedUser; // } // // // public void setAssignedUser(String assignedUser) // { // this.assignedUser = assignedUser; // } // // // public abstract String getCrmEntityType(); // // // public String getRelatedObjectId() // { // return relatedObjectId; // } // // // public void setRelatedObjectId(String relatedObjectId) // { // this.relatedObjectId = relatedObjectId; // } // // // public AbstractCrmObject() // { // super(); // } // // // public AbstractCrmObject(String id, String title) // { // super(); // this.id = id; // this.title = title; // } // // // public String getId() // { // return id; // } // // // public String getViewUrl() // { // return viewUrl; // } // // // public void setViewUrl(String viewUrl) // { // this.viewUrl = viewUrl; // } // // // public String getEditUrl() // { // return editUrl; // } // // // public void setEditUrl(String editUrl) // { // this.editUrl = editUrl; // } // // // public String getRelatedObjectType() // { // return relatedObjectType; // } // // // public void setRelatedObjectType(String relatedObjectType) // { // this.relatedObjectType = relatedObjectType; // } // // // public String getRelatedObjectUrl() // { // return relatedObjectUrl; // } // // // public void setRelatedObjectUrl(String realtedObjectUrl) // { // this.relatedObjectUrl = realtedObjectUrl; // } // // // public String getTitle() // { // return title; // } // // // public void setTitle(String title) // { // this.title = title; // } // // // @Override // public String toString() // { // return title; // } // // }
import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import javax.swing.JButton; import javax.swing.table.AbstractTableModel; import net.combase.desktopcrm.domain.AbstractCrmObject;
/** * */ package net.combase.desktopcrm.swing; /** * @author "Till Freier" * */ public class ActionRequiredTableModel extends AbstractTableModel { /** * */ private static final long serialVersionUID = -3890791456083674319L; private static final String[] COLUMN_NAMES = new String[] { "Title", "Owner", "" }; private static final Class<?>[] COLUMN_TYPES = new Class<?>[] { String.class, String.class, JButton.class };
// Path: src/main/java/net/combase/desktopcrm/domain/AbstractCrmObject.java // public abstract class AbstractCrmObject // { // private String id; // // private String viewUrl; // // private String editUrl; // // private String relatedObjectType; // // private String relatedObjectUrl; // // private String relatedObjectId; // // private String title; // // private String activitiesUrl; // // // /** // * @return the activitiesUrl // */ // public String getActivitiesUrl() // { // return activitiesUrl; // } // // // /** // * @param activitiesUrl the activitiesUrl to set // */ // public void setActivitiesUrl(String activitiesUrl) // { // this.activitiesUrl = activitiesUrl; // } // // // private String assignedUser; // // // public String getAssignedUser() // { // return assignedUser; // } // // // public void setAssignedUser(String assignedUser) // { // this.assignedUser = assignedUser; // } // // // public abstract String getCrmEntityType(); // // // public String getRelatedObjectId() // { // return relatedObjectId; // } // // // public void setRelatedObjectId(String relatedObjectId) // { // this.relatedObjectId = relatedObjectId; // } // // // public AbstractCrmObject() // { // super(); // } // // // public AbstractCrmObject(String id, String title) // { // super(); // this.id = id; // this.title = title; // } // // // public String getId() // { // return id; // } // // // public String getViewUrl() // { // return viewUrl; // } // // // public void setViewUrl(String viewUrl) // { // this.viewUrl = viewUrl; // } // // // public String getEditUrl() // { // return editUrl; // } // // // public void setEditUrl(String editUrl) // { // this.editUrl = editUrl; // } // // // public String getRelatedObjectType() // { // return relatedObjectType; // } // // // public void setRelatedObjectType(String relatedObjectType) // { // this.relatedObjectType = relatedObjectType; // } // // // public String getRelatedObjectUrl() // { // return relatedObjectUrl; // } // // // public void setRelatedObjectUrl(String realtedObjectUrl) // { // this.relatedObjectUrl = realtedObjectUrl; // } // // // public String getTitle() // { // return title; // } // // // public void setTitle(String title) // { // this.title = title; // } // // // @Override // public String toString() // { // return title; // } // // } // Path: src/main/java/net/combase/desktopcrm/swing/ActionRequiredTableModel.java import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.List; import javax.swing.JButton; import javax.swing.table.AbstractTableModel; import net.combase.desktopcrm.domain.AbstractCrmObject; /** * */ package net.combase.desktopcrm.swing; /** * @author "Till Freier" * */ public class ActionRequiredTableModel extends AbstractTableModel { /** * */ private static final long serialVersionUID = -3890791456083674319L; private static final String[] COLUMN_NAMES = new String[] { "Title", "Owner", "" }; private static final Class<?>[] COLUMN_TYPES = new Class<?>[] { String.class, String.class, JButton.class };
private final List<AbstractCrmObject> data;
phuonglh/vn.vitk
src/main/java/vn/vitk/tok/WhitespaceClassifier.java
// Path: src/main/java/vn/vitk/util/SparkContextFactory.java // public class SparkContextFactory { // private static volatile JavaSparkContext jsc = null; // // private SparkContextFactory() {} // // public static JavaSparkContext create(String appName, String master) { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf().setAppName(appName).setMaster(master); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // // public static JavaSparkContext create(String master) { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf() // .setAppName("vn.vitk") // .setMaster(master); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // // public static JavaSparkContext create() { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf() // .setAppName("vn.vitk") // .setMaster("local[*]"); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // }
import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.regex.Pattern; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.ml.Pipeline; import org.apache.spark.ml.PipelineModel; import org.apache.spark.ml.PipelineStage; import org.apache.spark.ml.classification.LogisticRegression; import org.apache.spark.ml.classification.LogisticRegressionModel; import org.apache.spark.ml.classification.LogisticRegressionTrainingSummary; import org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator; import org.apache.spark.ml.feature.HashingTF; import org.apache.spark.ml.feature.Tokenizer; import org.apache.spark.sql.DataFrame; import org.apache.spark.sql.SQLContext; import vn.vitk.util.SparkContextFactory;
package vn.vitk.tok; /** * @author Phuong LE-HONG, <phuonglh@gmail.com> * <p> * Apr 25, 2016, 4:51:27 PM * <p> * Whitespace classifier with logistic regression. */ public class WhitespaceClassifier implements Serializable { private static final long serialVersionUID = 3100732272743758977L;
// Path: src/main/java/vn/vitk/util/SparkContextFactory.java // public class SparkContextFactory { // private static volatile JavaSparkContext jsc = null; // // private SparkContextFactory() {} // // public static JavaSparkContext create(String appName, String master) { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf().setAppName(appName).setMaster(master); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // // public static JavaSparkContext create(String master) { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf() // .setAppName("vn.vitk") // .setMaster(master); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // // public static JavaSparkContext create() { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf() // .setAppName("vn.vitk") // .setMaster("local[*]"); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // } // Path: src/main/java/vn/vitk/tok/WhitespaceClassifier.java import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.regex.Pattern; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.ml.Pipeline; import org.apache.spark.ml.PipelineModel; import org.apache.spark.ml.PipelineStage; import org.apache.spark.ml.classification.LogisticRegression; import org.apache.spark.ml.classification.LogisticRegressionModel; import org.apache.spark.ml.classification.LogisticRegressionTrainingSummary; import org.apache.spark.ml.evaluation.MulticlassClassificationEvaluator; import org.apache.spark.ml.feature.HashingTF; import org.apache.spark.ml.feature.Tokenizer; import org.apache.spark.sql.DataFrame; import org.apache.spark.sql.SQLContext; import vn.vitk.util.SparkContextFactory; package vn.vitk.tok; /** * @author Phuong LE-HONG, <phuonglh@gmail.com> * <p> * Apr 25, 2016, 4:51:27 PM * <p> * Whitespace classifier with logistic regression. */ public class WhitespaceClassifier implements Serializable { private static final long serialVersionUID = 3100732272743758977L;
private transient JavaSparkContext jsc = SparkContextFactory.create();
phuonglh/vn.vitk
src/main/java/vn/vitk/tok/Tokenizer.java
// Path: src/main/java/vn/vitk/util/SparkContextFactory.java // public class SparkContextFactory { // private static volatile JavaSparkContext jsc = null; // // private SparkContextFactory() {} // // public static JavaSparkContext create(String appName, String master) { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf().setAppName(appName).setMaster(master); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // // public static JavaSparkContext create(String master) { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf() // .setAppName("vn.vitk") // .setMaster(master); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // // public static JavaSparkContext create() { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf() // .setAppName("vn.vitk") // .setMaster("local[*]"); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // }
import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; import org.apache.spark.Accumulator; import org.apache.spark.AccumulatorParam; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.api.java.function.Function; import org.apache.spark.api.java.function.Function2; import org.apache.spark.broadcast.Broadcast; import org.apache.spark.ml.PipelineModel; import org.apache.spark.sql.DataFrame; import org.apache.spark.sql.Row; import org.apache.spark.sql.SQLContext; import scala.Tuple2; import vn.vitk.util.SparkContextFactory; import de.l3s.boilerpipe.BoilerpipeProcessingException; import de.l3s.boilerpipe.extractors.ArticleExtractor;
package vn.vitk.tok; /** * @author Phuong LE-HONG * <p> * Mar 11, 2016, 10:20:06 AM * <p> * Fast and simple reimplementation of <code>vnTokenizer</code> tool. */ public class Tokenizer implements Serializable { private static final long serialVersionUID = 216079852616487675L; private transient JavaSparkContext jsc; private Lexicon lexicon = new Lexicon(); private Map<String, Pattern> patterns = new TreeMap<String, Pattern>(); private TextNormalizationFunction normalizationFunction = new TextNormalizationFunction(); private PhraseGraph graph = new PhraseGraph(); private Bigrams bigram = null; private WhitespaceClassifier classifier = null; private Accumulator<List<WhitespaceContext>> contexts; private PipelineModel model = null; private Broadcast<Row[]> prediction = null; private int counter = 0; private boolean verbose = false; /** * Creates a Vietnamese tokenizer. * @param master * @param lexiconFileName * @param regexpFileName */ public Tokenizer(String master, String lexiconFileName, String regexpFileName) {
// Path: src/main/java/vn/vitk/util/SparkContextFactory.java // public class SparkContextFactory { // private static volatile JavaSparkContext jsc = null; // // private SparkContextFactory() {} // // public static JavaSparkContext create(String appName, String master) { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf().setAppName(appName).setMaster(master); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // // public static JavaSparkContext create(String master) { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf() // .setAppName("vn.vitk") // .setMaster(master); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // // public static JavaSparkContext create() { // if (jsc == null) { // synchronized (SparkContextFactory.class) { // if (jsc == null) { // SparkConf sc = new SparkConf() // .setAppName("vn.vitk") // .setMaster("local[*]"); // jsc = new JavaSparkContext(sc); // } // } // } // return jsc; // } // } // Path: src/main/java/vn/vitk/tok/Tokenizer.java import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; import org.apache.spark.Accumulator; import org.apache.spark.AccumulatorParam; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.api.java.function.Function; import org.apache.spark.api.java.function.Function2; import org.apache.spark.broadcast.Broadcast; import org.apache.spark.ml.PipelineModel; import org.apache.spark.sql.DataFrame; import org.apache.spark.sql.Row; import org.apache.spark.sql.SQLContext; import scala.Tuple2; import vn.vitk.util.SparkContextFactory; import de.l3s.boilerpipe.BoilerpipeProcessingException; import de.l3s.boilerpipe.extractors.ArticleExtractor; package vn.vitk.tok; /** * @author Phuong LE-HONG * <p> * Mar 11, 2016, 10:20:06 AM * <p> * Fast and simple reimplementation of <code>vnTokenizer</code> tool. */ public class Tokenizer implements Serializable { private static final long serialVersionUID = 216079852616487675L; private transient JavaSparkContext jsc; private Lexicon lexicon = new Lexicon(); private Map<String, Pattern> patterns = new TreeMap<String, Pattern>(); private TextNormalizationFunction normalizationFunction = new TextNormalizationFunction(); private PhraseGraph graph = new PhraseGraph(); private Bigrams bigram = null; private WhitespaceClassifier classifier = null; private Accumulator<List<WhitespaceContext>> contexts; private PipelineModel model = null; private Broadcast<Row[]> prediction = null; private int counter = 0; private boolean verbose = false; /** * Creates a Vietnamese tokenizer. * @param master * @param lexiconFileName * @param regexpFileName */ public Tokenizer(String master, String lexiconFileName, String regexpFileName) {
jsc = SparkContextFactory.create(master);
phuonglh/vn.vitk
src/main/java/vn/vitk/tag/ContextExtractor.java
// Path: src/main/java/vn/vitk/util/Converter.java // public class Converter implements Serializable { // private static final long serialVersionUID = -8916193514910249287L; // // private Map<String, Pattern> patterns = new HashMap<String, Pattern>(); // // public Converter(String regexpFileName) { // BufferedReader br = null; // try { // br = new BufferedReader(new InputStreamReader(new FileInputStream(regexpFileName), "UTF-8")); // String line = null; // while ((line = br.readLine()) != null) { // String[] parts = line.trim().split("\\s+"); // if (parts.length == 2) { // patterns.put(parts[0].trim(), Pattern.compile(parts[1].trim())); // } else { // System.err.println("Bad format regexp file: " + line); // } // } // br.close(); // } catch (IOException e) { // e.printStackTrace(); // } finally { // try { // br.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // } // // public String convert(String token) { // for (String type : patterns.keySet()) { // Pattern pattern = patterns.get(type); // String t = token.replace('_', ' '); // if (pattern.matcher(t).matches()) { // if (type.contains("entity")) // return "entity"; // else if (type.contains("name")) // return "name"; // else if (type.contains("allcap")) // return "allcap"; // else if (type.contains("email")) // return "email"; // else if (type.contains("date")) // return "date"; // else if (type.contains("hour")) // return "hour"; // else if (type.contains("number")) // return "number"; // else if (type.contains("fraction")) // return "fraction"; // else if (type.contains("punctuation")) // return "punct"; // } // } // return "normal"; // } // // public static void main(String[] args) { // Converter transformer = new Converter("dat/tok/regexp.txt"); // String[] tokens = {"H5N1", "H5N1;Np", "2006/11/12", "22/07/2012;D", "khanhlh@mail.com", "12:05", "299.2", "33/3", "Jean-Claude Juncker", "Lê Hồng Quang", "không có gì"}; // for (String token : tokens) // System.out.println(token + "=>" + transformer.convert(token)); // } // }
import java.io.Serializable; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.function.FlatMapFunction; import org.apache.spark.sql.Row; import scala.Tuple2; import vn.vitk.util.Converter;
package vn.vitk.tag; /** * @author Phuong LE-HONG * <p> * May 11, 2016, 5:57:52 PM * <p> * A context extractor extracts all labeled contexts from a training dataset * containing labeled sequences. * */ public class ContextExtractor implements Serializable { private static final long serialVersionUID = 6481557600701316137L; private MarkovOrder markovOrder = MarkovOrder.FIRST;
// Path: src/main/java/vn/vitk/util/Converter.java // public class Converter implements Serializable { // private static final long serialVersionUID = -8916193514910249287L; // // private Map<String, Pattern> patterns = new HashMap<String, Pattern>(); // // public Converter(String regexpFileName) { // BufferedReader br = null; // try { // br = new BufferedReader(new InputStreamReader(new FileInputStream(regexpFileName), "UTF-8")); // String line = null; // while ((line = br.readLine()) != null) { // String[] parts = line.trim().split("\\s+"); // if (parts.length == 2) { // patterns.put(parts[0].trim(), Pattern.compile(parts[1].trim())); // } else { // System.err.println("Bad format regexp file: " + line); // } // } // br.close(); // } catch (IOException e) { // e.printStackTrace(); // } finally { // try { // br.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // } // // public String convert(String token) { // for (String type : patterns.keySet()) { // Pattern pattern = patterns.get(type); // String t = token.replace('_', ' '); // if (pattern.matcher(t).matches()) { // if (type.contains("entity")) // return "entity"; // else if (type.contains("name")) // return "name"; // else if (type.contains("allcap")) // return "allcap"; // else if (type.contains("email")) // return "email"; // else if (type.contains("date")) // return "date"; // else if (type.contains("hour")) // return "hour"; // else if (type.contains("number")) // return "number"; // else if (type.contains("fraction")) // return "fraction"; // else if (type.contains("punctuation")) // return "punct"; // } // } // return "normal"; // } // // public static void main(String[] args) { // Converter transformer = new Converter("dat/tok/regexp.txt"); // String[] tokens = {"H5N1", "H5N1;Np", "2006/11/12", "22/07/2012;D", "khanhlh@mail.com", "12:05", "299.2", "33/3", "Jean-Claude Juncker", "Lê Hồng Quang", "không có gì"}; // for (String token : tokens) // System.out.println(token + "=>" + transformer.convert(token)); // } // } // Path: src/main/java/vn/vitk/tag/ContextExtractor.java import java.io.Serializable; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.function.FlatMapFunction; import org.apache.spark.sql.Row; import scala.Tuple2; import vn.vitk.util.Converter; package vn.vitk.tag; /** * @author Phuong LE-HONG * <p> * May 11, 2016, 5:57:52 PM * <p> * A context extractor extracts all labeled contexts from a training dataset * containing labeled sequences. * */ public class ContextExtractor implements Serializable { private static final long serialVersionUID = 6481557600701316137L; private MarkovOrder markovOrder = MarkovOrder.FIRST;
private Converter tokenConverter;
phuonglh/vn.vitk
src/main/java/vn/vitk/tag/CMMModel.java
// Path: src/main/java/vn/vitk/util/Constants.java // public interface Constants { // public static final String REGEXP_FILE = "/export/dat/tok/regexp.txt"; // }
import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import org.apache.hadoop.fs.Path; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.function.Function; import org.apache.spark.ml.Model; import org.apache.spark.ml.PipelineModel; import org.apache.spark.ml.feature.CountVectorizerModel; import org.apache.spark.ml.feature.StringIndexerModel; import org.apache.spark.ml.param.ParamMap; import org.apache.spark.ml.util.DefaultParamsReader; import org.apache.spark.ml.util.DefaultParamsWriter; import org.apache.spark.ml.util.MLReader; import org.apache.spark.ml.util.MLWritable; import org.apache.spark.ml.util.MLWriter; import org.apache.spark.ml.util.SchemaUtils; import org.apache.spark.mllib.linalg.Vector; import org.apache.spark.mllib.linalg.Vectors; import org.apache.spark.mllib.util.MLUtils; import org.apache.spark.sql.DataFrame; import org.apache.spark.sql.Row; import org.apache.spark.sql.RowFactory; import org.apache.spark.sql.types.DataTypes; import org.apache.spark.sql.types.Metadata; import org.apache.spark.sql.types.StructField; import org.apache.spark.sql.types.StructType; import scala.Tuple2; import scala.collection.Iterator; import scala.collection.mutable.WrappedArray; import vn.vitk.util.Constants;
package vn.vitk.tag; /** * @author Phuong LE-HONG * <p> * May 9, 2016, 5:52:38 PM * <p> * A conditional Markov model (or Maximum-Entropy Markov model -- MEMM) * for sequence labeling which is fitted by a CMM graphical model. * */ public class CMMModel extends Model<CMMModel> implements MLWritable { private static final long serialVersionUID = -4855076361905836432L; private PipelineModel pipelineModel; private ContextExtractor contextExtractor; private final Vector weights; private final String[] tags; private final Map<String, Integer> featureMap; private final Map<String, Set<Integer>> tagDictionary; /** * Creates a conditional Markov model. * @param pipelineModel * @param weights * @param markovOrder */ public CMMModel(PipelineModel pipelineModel, Vector weights, MarkovOrder markovOrder, Map<String, Set<Integer>> tagDictionary) { this.pipelineModel = pipelineModel;
// Path: src/main/java/vn/vitk/util/Constants.java // public interface Constants { // public static final String REGEXP_FILE = "/export/dat/tok/regexp.txt"; // } // Path: src/main/java/vn/vitk/tag/CMMModel.java import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import org.apache.hadoop.fs.Path; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.function.Function; import org.apache.spark.ml.Model; import org.apache.spark.ml.PipelineModel; import org.apache.spark.ml.feature.CountVectorizerModel; import org.apache.spark.ml.feature.StringIndexerModel; import org.apache.spark.ml.param.ParamMap; import org.apache.spark.ml.util.DefaultParamsReader; import org.apache.spark.ml.util.DefaultParamsWriter; import org.apache.spark.ml.util.MLReader; import org.apache.spark.ml.util.MLWritable; import org.apache.spark.ml.util.MLWriter; import org.apache.spark.ml.util.SchemaUtils; import org.apache.spark.mllib.linalg.Vector; import org.apache.spark.mllib.linalg.Vectors; import org.apache.spark.mllib.util.MLUtils; import org.apache.spark.sql.DataFrame; import org.apache.spark.sql.Row; import org.apache.spark.sql.RowFactory; import org.apache.spark.sql.types.DataTypes; import org.apache.spark.sql.types.Metadata; import org.apache.spark.sql.types.StructField; import org.apache.spark.sql.types.StructType; import scala.Tuple2; import scala.collection.Iterator; import scala.collection.mutable.WrappedArray; import vn.vitk.util.Constants; package vn.vitk.tag; /** * @author Phuong LE-HONG * <p> * May 9, 2016, 5:52:38 PM * <p> * A conditional Markov model (or Maximum-Entropy Markov model -- MEMM) * for sequence labeling which is fitted by a CMM graphical model. * */ public class CMMModel extends Model<CMMModel> implements MLWritable { private static final long serialVersionUID = -4855076361905836432L; private PipelineModel pipelineModel; private ContextExtractor contextExtractor; private final Vector weights; private final String[] tags; private final Map<String, Integer> featureMap; private final Map<String, Set<Integer>> tagDictionary; /** * Creates a conditional Markov model. * @param pipelineModel * @param weights * @param markovOrder */ public CMMModel(PipelineModel pipelineModel, Vector weights, MarkovOrder markovOrder, Map<String, Set<Integer>> tagDictionary) { this.pipelineModel = pipelineModel;
this.contextExtractor = new ContextExtractor(markovOrder, Constants.REGEXP_FILE);
phuonglh/vn.vitk
src/main/java/vn/vitk/dep/FeatureExtractor.java
// Path: src/main/java/vn/vitk/util/TokenNormalizer.java // public class TokenNormalizer { // // static Pattern number = Pattern.compile("^([\\+\\-\\.,]?([0-9]*)?[0-9]+([\\.,]\\d+)*[%°]?)$"); // static Pattern punctuation = Pattern.compile("^([\\?!\\.:;,\\-\\+\\*\"'\\(\\)\\[\\]\\{\\}]+)$"); // static Pattern email = Pattern.compile("^(\\w[\\-\\._\\w]*\\w@\\w[\\-\\._\\w]*\\w\\.\\w{2,3})$"); // static Pattern date = Pattern.compile("^(\\d+[\\-\\./]\\d+([\\-\\./]\\d+)?)$|^(năm_)\\d+$"); // static Pattern code = Pattern.compile("^(\\d+[\\-\\._/]?[\\w\\W\\-\\._/]+)$|^([\\w\\W\\-\\._/]+\\d+[\\-\\._/\\d]*[\\w\\W]*)$"); // static Pattern website = Pattern.compile("^(\\w+\\.\\w+)(/\\w*)*$"); // static Pattern xmlTag = Pattern.compile("^</?\\w+>$"); // // // private static boolean isNumber(String token) { // return number.matcher(token).matches(); // } // // private static boolean isPunctuation(String token) { // return punctuation.matcher(token).matches(); // } // // private static boolean isEmail(String token) { // return email.matcher(token).matches(); // } // // private static boolean isDate(String token) { // return date.matcher(token).matches(); // } // // private static boolean isCode(String token) { // return code.matcher(token).matches(); // } // // private static boolean isWebsite(String token) { // return website.matcher(token).matches(); // } // // private static boolean isTag(String token) { // return xmlTag.matcher(token).matches(); // } // // /** // * Normalizes the token. // * @param token // * @return a normalized token. // */ // public static String normalize(String token) { // if (isNumber(token)) // return "1000"; // if (isPunctuation(token)) // return "PUNCT"; // if (isEmail(token)) // return "EMAIL"; // if (isDate(token)) // return "DATE"; // if (isCode(token)) // return "CODE"; // if (isWebsite(token)) // return "WEBSITE"; // if (isTag(token)) // return "XMLTAG"; // return token; // } // // }
import java.util.ArrayList; import java.util.List; import vn.vitk.util.TokenNormalizer;
public String extract(Configuration configuration) { int n = configuration.getQueue().size(); if (n < 2) { return "tq1:NULL"; } Integer q1 = configuration.getQueue().toArray(new Integer[n])[1]; return "tq1:" + configuration.getSentence().getTag(q1); } } class Queue01Tags implements Extractor { @Override public String extract(Configuration configuration) { Integer q0 = configuration.getQueue().peek(); String tq0 = configuration.getSentence().getTag(q0); int n = configuration.getQueue().size(); if (n < 2) { return "tq0+tq1:" + tq0 + "+NULL"; } Integer q1 = configuration.getQueue().toArray(new Integer[n])[1]; String tq1 = configuration.getSentence().getTag(q1); return "tq0+tq1:" + tq0 + '+' + tq1; } } class Stack0Token implements Extractor { @Override public String extract(Configuration configuration) { Integer s0 = configuration.getStack().peek(); String token = configuration.getSentence().getToken(s0);
// Path: src/main/java/vn/vitk/util/TokenNormalizer.java // public class TokenNormalizer { // // static Pattern number = Pattern.compile("^([\\+\\-\\.,]?([0-9]*)?[0-9]+([\\.,]\\d+)*[%°]?)$"); // static Pattern punctuation = Pattern.compile("^([\\?!\\.:;,\\-\\+\\*\"'\\(\\)\\[\\]\\{\\}]+)$"); // static Pattern email = Pattern.compile("^(\\w[\\-\\._\\w]*\\w@\\w[\\-\\._\\w]*\\w\\.\\w{2,3})$"); // static Pattern date = Pattern.compile("^(\\d+[\\-\\./]\\d+([\\-\\./]\\d+)?)$|^(năm_)\\d+$"); // static Pattern code = Pattern.compile("^(\\d+[\\-\\._/]?[\\w\\W\\-\\._/]+)$|^([\\w\\W\\-\\._/]+\\d+[\\-\\._/\\d]*[\\w\\W]*)$"); // static Pattern website = Pattern.compile("^(\\w+\\.\\w+)(/\\w*)*$"); // static Pattern xmlTag = Pattern.compile("^</?\\w+>$"); // // // private static boolean isNumber(String token) { // return number.matcher(token).matches(); // } // // private static boolean isPunctuation(String token) { // return punctuation.matcher(token).matches(); // } // // private static boolean isEmail(String token) { // return email.matcher(token).matches(); // } // // private static boolean isDate(String token) { // return date.matcher(token).matches(); // } // // private static boolean isCode(String token) { // return code.matcher(token).matches(); // } // // private static boolean isWebsite(String token) { // return website.matcher(token).matches(); // } // // private static boolean isTag(String token) { // return xmlTag.matcher(token).matches(); // } // // /** // * Normalizes the token. // * @param token // * @return a normalized token. // */ // public static String normalize(String token) { // if (isNumber(token)) // return "1000"; // if (isPunctuation(token)) // return "PUNCT"; // if (isEmail(token)) // return "EMAIL"; // if (isDate(token)) // return "DATE"; // if (isCode(token)) // return "CODE"; // if (isWebsite(token)) // return "WEBSITE"; // if (isTag(token)) // return "XMLTAG"; // return token; // } // // } // Path: src/main/java/vn/vitk/dep/FeatureExtractor.java import java.util.ArrayList; import java.util.List; import vn.vitk.util.TokenNormalizer; public String extract(Configuration configuration) { int n = configuration.getQueue().size(); if (n < 2) { return "tq1:NULL"; } Integer q1 = configuration.getQueue().toArray(new Integer[n])[1]; return "tq1:" + configuration.getSentence().getTag(q1); } } class Queue01Tags implements Extractor { @Override public String extract(Configuration configuration) { Integer q0 = configuration.getQueue().peek(); String tq0 = configuration.getSentence().getTag(q0); int n = configuration.getQueue().size(); if (n < 2) { return "tq0+tq1:" + tq0 + "+NULL"; } Integer q1 = configuration.getQueue().toArray(new Integer[n])[1]; String tq1 = configuration.getSentence().getTag(q1); return "tq0+tq1:" + tq0 + '+' + tq1; } } class Stack0Token implements Extractor { @Override public String extract(Configuration configuration) { Integer s0 = configuration.getStack().peek(); String token = configuration.getSentence().getToken(s0);
return "ws0:" + TokenNormalizer.normalize(token);
phuonglh/vn.vitk
src/main/java/vn/vitk/dep/DependencyGraphStatistics.java
// Path: src/main/java/vn/vitk/util/MapUtil.java // public class MapUtil { // // /** // * Sorts a map by value. // * @param map // * @return a map whose values are sorted. // */ // public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) { // List<Map.Entry<K, V>> list = new LinkedList<Map.Entry<K, V>>(map.entrySet()); // Collections.sort(list, new Comparator<Map.Entry<K, V>>() { // public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2) { // return -(o1.getValue()).compareTo(o2.getValue()); // } // }); // // Map<K, V> result = new LinkedHashMap<K, V>(); // for (Map.Entry<K, V> entry : list) { // result.put(entry.getKey(), entry.getValue()); // } // return result; // } // }
import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; import scala.Tuple2; import vn.vitk.util.MapUtil;
public static void main(String[] args) { // String corpusFileName = "/export/dat/udt/en/en-ud-train.conllu"; // String corpusFileName = "/export/dat/udt/en/en-ud-test.conllu"; // List<DependencyGraph> graphs = DependencyGraphReader.readCoNLLU(corpusFileName); String corpusFileName = "/export/dat/udt/vi/dataAll.conll"; List<DependencyGraph> graphs = DependencyGraphReader.read(corpusFileName, 'x'); Map<Tuple2<String, String>, Integer> map = headDependentMap(graphs); System.out.println("#(tuples) = " + map.size()); for (Tuple2<String, String> tuple : map.keySet()) { System.out.println(tuple + ":" + map.get(tuple)); } System.out.println(); Map<String, Map<String, Integer>> heads = headMap(graphs); System.out.println("#(head) = " + heads.size()); for (String head : heads.keySet()) { System.out.println(head); Map<String, Integer> dependents = heads.get(head); System.out.println("\t" + dependents.size() + " dependents."); System.out.println("\t" + heads.get(head)); } // get possible root PoS tags, ordered by frequency // System.out.println(); System.out.println("root PoS: "); Map<String, Integer> dependentsOfRoot = heads.get("ROOT");
// Path: src/main/java/vn/vitk/util/MapUtil.java // public class MapUtil { // // /** // * Sorts a map by value. // * @param map // * @return a map whose values are sorted. // */ // public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) { // List<Map.Entry<K, V>> list = new LinkedList<Map.Entry<K, V>>(map.entrySet()); // Collections.sort(list, new Comparator<Map.Entry<K, V>>() { // public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2) { // return -(o1.getValue()).compareTo(o2.getValue()); // } // }); // // Map<K, V> result = new LinkedHashMap<K, V>(); // for (Map.Entry<K, V> entry : list) { // result.put(entry.getKey(), entry.getValue()); // } // return result; // } // } // Path: src/main/java/vn/vitk/dep/DependencyGraphStatistics.java import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; import scala.Tuple2; import vn.vitk.util.MapUtil; public static void main(String[] args) { // String corpusFileName = "/export/dat/udt/en/en-ud-train.conllu"; // String corpusFileName = "/export/dat/udt/en/en-ud-test.conllu"; // List<DependencyGraph> graphs = DependencyGraphReader.readCoNLLU(corpusFileName); String corpusFileName = "/export/dat/udt/vi/dataAll.conll"; List<DependencyGraph> graphs = DependencyGraphReader.read(corpusFileName, 'x'); Map<Tuple2<String, String>, Integer> map = headDependentMap(graphs); System.out.println("#(tuples) = " + map.size()); for (Tuple2<String, String> tuple : map.keySet()) { System.out.println(tuple + ":" + map.get(tuple)); } System.out.println(); Map<String, Map<String, Integer>> heads = headMap(graphs); System.out.println("#(head) = " + heads.size()); for (String head : heads.keySet()) { System.out.println(head); Map<String, Integer> dependents = heads.get(head); System.out.println("\t" + dependents.size() + " dependents."); System.out.println("\t" + heads.get(head)); } // get possible root PoS tags, ordered by frequency // System.out.println(); System.out.println("root PoS: "); Map<String, Integer> dependentsOfRoot = heads.get("ROOT");
Map<String, Integer> sortedDoR = MapUtil.sortByValue(dependentsOfRoot);
phuonglh/vn.vitk
src/main/java/vn/vitk/tag/CMM.java
// Path: src/main/java/vn/vitk/util/Constants.java // public interface Constants { // public static final String REGEXP_FILE = "/export/dat/tok/regexp.txt"; // }
import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.UUID; import org.apache.spark.api.java.JavaPairRDD; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.function.Function; import org.apache.spark.api.java.function.Function2; import org.apache.spark.api.java.function.PairFunction; import org.apache.spark.ml.Estimator; import org.apache.spark.ml.Pipeline; import org.apache.spark.ml.PipelineModel; import org.apache.spark.ml.PipelineStage; import org.apache.spark.ml.feature.CountVectorizer; import org.apache.spark.ml.feature.CountVectorizerModel; import org.apache.spark.ml.feature.StringIndexer; import org.apache.spark.ml.feature.Tokenizer; import org.apache.spark.ml.param.ParamMap; import org.apache.spark.mllib.linalg.Vector; import org.apache.spark.mllib.linalg.Vectors; import org.apache.spark.mllib.optimization.LBFGS; import org.apache.spark.mllib.optimization.LogisticGradient; import org.apache.spark.mllib.optimization.SquaredL2Updater; import org.apache.spark.mllib.util.MLUtils; import org.apache.spark.sql.DataFrame; import org.apache.spark.sql.Row; import org.apache.spark.sql.types.StructType; import scala.Tuple2; import vn.vitk.util.Constants;
package vn.vitk.tag; /** * @author Phuong LE-HONG * <p> * May 9, 2016, 6:09:08 PM * <p> * Conditional Markov model for sequence labeling. This models is also * called Maximum-Entropy Markov model (MEMM). * <p> * The input of this estimator is a data frame containing two columns: "featureStrings" * and "label". * */ public class CMM extends Estimator<CMMModel> { private static final long serialVersionUID = -6366026106299743238L; private String uid = null; private int numLabels = 0; private CMMParams params; private boolean verbose = false; /** * Constructs a Conditional Markov Model for sequence labeling with default * parameters for use in training. */ public CMM() { params = new CMMParams(); } /** * Creates a Conditioanl Markov model for sequence labeling with given * parameters for use in training. * @param params */ public CMM(CMMParams params) { this.params = params; } /* (non-Javadoc) * @see org.apache.spark.ml.util.Identifiable#uid() */ @Override public String uid() { if (uid == null) { String ruid = UUID.randomUUID().toString(); int n = ruid.length(); uid = "cmm" + "_" + ruid.substring(n-12, n); } return uid; } /* (non-Javadoc) * @see org.apache.spark.ml.Estimator#copy(org.apache.spark.ml.param.ParamMap) */ @Override public Estimator<CMMModel> copy(ParamMap extra) { return defaultCopy(extra); } /* (non-Javadoc) * @see org.apache.spark.ml.Estimator#fit(org.apache.spark.sql.DataFrame) */ @Override public CMMModel fit(DataFrame dataset) { MarkovOrder order = MarkovOrder.values()[(Integer)params.getOrDefault(params.getMarkovOrder())-1];
// Path: src/main/java/vn/vitk/util/Constants.java // public interface Constants { // public static final String REGEXP_FILE = "/export/dat/tok/regexp.txt"; // } // Path: src/main/java/vn/vitk/tag/CMM.java import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.UUID; import org.apache.spark.api.java.JavaPairRDD; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.function.Function; import org.apache.spark.api.java.function.Function2; import org.apache.spark.api.java.function.PairFunction; import org.apache.spark.ml.Estimator; import org.apache.spark.ml.Pipeline; import org.apache.spark.ml.PipelineModel; import org.apache.spark.ml.PipelineStage; import org.apache.spark.ml.feature.CountVectorizer; import org.apache.spark.ml.feature.CountVectorizerModel; import org.apache.spark.ml.feature.StringIndexer; import org.apache.spark.ml.feature.Tokenizer; import org.apache.spark.ml.param.ParamMap; import org.apache.spark.mllib.linalg.Vector; import org.apache.spark.mllib.linalg.Vectors; import org.apache.spark.mllib.optimization.LBFGS; import org.apache.spark.mllib.optimization.LogisticGradient; import org.apache.spark.mllib.optimization.SquaredL2Updater; import org.apache.spark.mllib.util.MLUtils; import org.apache.spark.sql.DataFrame; import org.apache.spark.sql.Row; import org.apache.spark.sql.types.StructType; import scala.Tuple2; import vn.vitk.util.Constants; package vn.vitk.tag; /** * @author Phuong LE-HONG * <p> * May 9, 2016, 6:09:08 PM * <p> * Conditional Markov model for sequence labeling. This models is also * called Maximum-Entropy Markov model (MEMM). * <p> * The input of this estimator is a data frame containing two columns: "featureStrings" * and "label". * */ public class CMM extends Estimator<CMMModel> { private static final long serialVersionUID = -6366026106299743238L; private String uid = null; private int numLabels = 0; private CMMParams params; private boolean verbose = false; /** * Constructs a Conditional Markov Model for sequence labeling with default * parameters for use in training. */ public CMM() { params = new CMMParams(); } /** * Creates a Conditioanl Markov model for sequence labeling with given * parameters for use in training. * @param params */ public CMM(CMMParams params) { this.params = params; } /* (non-Javadoc) * @see org.apache.spark.ml.util.Identifiable#uid() */ @Override public String uid() { if (uid == null) { String ruid = UUID.randomUUID().toString(); int n = ruid.length(); uid = "cmm" + "_" + ruid.substring(n-12, n); } return uid; } /* (non-Javadoc) * @see org.apache.spark.ml.Estimator#copy(org.apache.spark.ml.param.ParamMap) */ @Override public Estimator<CMMModel> copy(ParamMap extra) { return defaultCopy(extra); } /* (non-Javadoc) * @see org.apache.spark.ml.Estimator#fit(org.apache.spark.sql.DataFrame) */ @Override public CMMModel fit(DataFrame dataset) { MarkovOrder order = MarkovOrder.values()[(Integer)params.getOrDefault(params.getMarkovOrder())-1];
ContextExtractor contextExtractor = new ContextExtractor(order, Constants.REGEXP_FILE);
rahulmaddineni/Stayfit
app/src/main/java/com/example/maddi/fitness/FoodSummaryActivity.java
// Path: progressviewslib/src/main/java/com/natasa/progressviews/CircleProgressBar.java // public class CircleProgressBar extends ProgressView { // // private int PADDING = 3; // private RectF rectF; // private float bottom; // private float right; // private float top; // private float left; // private float angle; // private int radius; // private boolean isGradientColor; // private boolean isSweepGradientColor; // private int colorStart, colorEnd; // // public CircleProgressBar(Context context) { // super(context); // } // // public CircleProgressBar(Context context, AttributeSet attrs, int defStyle) { // super(context, attrs, defStyle); // // } // // public CircleProgressBar(Context context, AttributeSet attrs) { // super(context, attrs); // } // // @Override // protected void init() { // rectF = new RectF(); // initBackgroundColor(); // initForegroundColor(); // // } // // //public void setRadialGradient() { // // ColorsHelper.setRadialGradientPaint(foregroundPaint, left, top, min); // //} // // @Override // protected void onDraw(Canvas canvas) { // super.onDraw(canvas); // drawGradientColor(); // drawStrokeCircle(canvas); // // } // // // private void drawStrokeCircle(Canvas canvas) { // // canvas.drawOval(rectF, backgroundPaint); // angle = 360 * getProgress() / maximum_progress; // canvas.drawArc(rectF, startPosInDegrees, angle, false, foregroundPaint); // drawText(canvas); // } // // // private void drawGradientColor() { // if (isGradientColor) { // setLinearGradientProgress(gradColors); // } // if (isSweepGradientColor) { // setSweepGradPaint(); // } // } // // public void setLinearGradientProgress(boolean isGradientColor) { // this.isGradientColor = isGradientColor; // } // // public void setLinearGradientProgress(boolean isGradientColor, int[] colors) { // this.isGradientColor = isGradientColor; // gradColors = colors; // // } // // public void setSweepGradientProgress(boolean isGradientColor, int colorStart, int colorEnd) { // this.isSweepGradientColor = isGradientColor; // this.colorStart = colorStart; // this.colorEnd = colorEnd; // // // } // // private void setSweepGradPaint() { // if (colorStart != 0 && colorEnd != 0 && colorHelper != null) { // colorHelper.setSweepGradientPaint(foregroundPaint, min / 2, min / 2, colorStart, colorEnd); // } // } // // private void setLinearGradientProgress(int[] gradColors) { // if (gradColors != null) // colorHelper.setGradientPaint(foregroundPaint, left, top, right, bottom, gradColors); // else // colorHelper.setGradientPaint(foregroundPaint, left, top, right, bottom); // // } // // public void setCircleViewPadding(int padding) { // PADDING = padding; // invalidate(); // } // // public int getPadding() { // return PADDING; // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // // left = 0 + strokeWidth / 2; // top = 0 + strokeWidth / 2; // right = min - strokeWidth / 2; // bottom = min - strokeWidth / 2; // rectF.set(left + PADDING, top + PADDING, right - PADDING, bottom // - PADDING); // } // // // *******************START POSITION FOR CIRCLE AND CIRCLE SEGMENT // // VIEW****************** // public int getProgressStartPosition() { // return startPosInDegrees; // } // // public void setStartPositionInDegrees(int degrees) { // this.startPosInDegrees = degrees; // } // // public void setStartPositionInDegrees(ProgressStartPoint position) { // this.startPosInDegrees = position.getValue(); // } // // @Override // public ShapeType setType(ShapeType type) { // return ShapeType.CIRCLE; // // } // // }
import android.graphics.Color; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.DisplayMetrics; import android.util.Log; import android.view.animation.BounceInterpolator; import android.view.animation.TranslateAnimation; import com.natasa.progressviews.CircleProgressBar;
package com.example.maddi.fitness; /** * Created by maddi on 4/20/2016. */ public class FoodSummaryActivity extends AppCompatActivity { float food_fat; float food_carbs; float food_protein; float max_fat = 70f; float max_carbs = 300f; float max_protein = 180f; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_foodsummary);
// Path: progressviewslib/src/main/java/com/natasa/progressviews/CircleProgressBar.java // public class CircleProgressBar extends ProgressView { // // private int PADDING = 3; // private RectF rectF; // private float bottom; // private float right; // private float top; // private float left; // private float angle; // private int radius; // private boolean isGradientColor; // private boolean isSweepGradientColor; // private int colorStart, colorEnd; // // public CircleProgressBar(Context context) { // super(context); // } // // public CircleProgressBar(Context context, AttributeSet attrs, int defStyle) { // super(context, attrs, defStyle); // // } // // public CircleProgressBar(Context context, AttributeSet attrs) { // super(context, attrs); // } // // @Override // protected void init() { // rectF = new RectF(); // initBackgroundColor(); // initForegroundColor(); // // } // // //public void setRadialGradient() { // // ColorsHelper.setRadialGradientPaint(foregroundPaint, left, top, min); // //} // // @Override // protected void onDraw(Canvas canvas) { // super.onDraw(canvas); // drawGradientColor(); // drawStrokeCircle(canvas); // // } // // // private void drawStrokeCircle(Canvas canvas) { // // canvas.drawOval(rectF, backgroundPaint); // angle = 360 * getProgress() / maximum_progress; // canvas.drawArc(rectF, startPosInDegrees, angle, false, foregroundPaint); // drawText(canvas); // } // // // private void drawGradientColor() { // if (isGradientColor) { // setLinearGradientProgress(gradColors); // } // if (isSweepGradientColor) { // setSweepGradPaint(); // } // } // // public void setLinearGradientProgress(boolean isGradientColor) { // this.isGradientColor = isGradientColor; // } // // public void setLinearGradientProgress(boolean isGradientColor, int[] colors) { // this.isGradientColor = isGradientColor; // gradColors = colors; // // } // // public void setSweepGradientProgress(boolean isGradientColor, int colorStart, int colorEnd) { // this.isSweepGradientColor = isGradientColor; // this.colorStart = colorStart; // this.colorEnd = colorEnd; // // // } // // private void setSweepGradPaint() { // if (colorStart != 0 && colorEnd != 0 && colorHelper != null) { // colorHelper.setSweepGradientPaint(foregroundPaint, min / 2, min / 2, colorStart, colorEnd); // } // } // // private void setLinearGradientProgress(int[] gradColors) { // if (gradColors != null) // colorHelper.setGradientPaint(foregroundPaint, left, top, right, bottom, gradColors); // else // colorHelper.setGradientPaint(foregroundPaint, left, top, right, bottom); // // } // // public void setCircleViewPadding(int padding) { // PADDING = padding; // invalidate(); // } // // public int getPadding() { // return PADDING; // } // // @Override // protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // super.onMeasure(widthMeasureSpec, heightMeasureSpec); // // left = 0 + strokeWidth / 2; // top = 0 + strokeWidth / 2; // right = min - strokeWidth / 2; // bottom = min - strokeWidth / 2; // rectF.set(left + PADDING, top + PADDING, right - PADDING, bottom // - PADDING); // } // // // *******************START POSITION FOR CIRCLE AND CIRCLE SEGMENT // // VIEW****************** // public int getProgressStartPosition() { // return startPosInDegrees; // } // // public void setStartPositionInDegrees(int degrees) { // this.startPosInDegrees = degrees; // } // // public void setStartPositionInDegrees(ProgressStartPoint position) { // this.startPosInDegrees = position.getValue(); // } // // @Override // public ShapeType setType(ShapeType type) { // return ShapeType.CIRCLE; // // } // // } // Path: app/src/main/java/com/example/maddi/fitness/FoodSummaryActivity.java import android.graphics.Color; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.util.DisplayMetrics; import android.util.Log; import android.view.animation.BounceInterpolator; import android.view.animation.TranslateAnimation; import com.natasa.progressviews.CircleProgressBar; package com.example.maddi.fitness; /** * Created by maddi on 4/20/2016. */ public class FoodSummaryActivity extends AppCompatActivity { float food_fat; float food_carbs; float food_protein; float max_fat = 70f; float max_carbs = 300f; float max_protein = 180f; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_foodsummary);
final CircleProgressBar fats = findViewById(R.id.fats_progress);
rahulmaddineni/Stayfit
app/libs/MPAndroidChart-2.2.3/MPAndroidChart-2.2.3/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityBubble.java
// Path: app/libs/MPAndroidChart-2.2.3/MPAndroidChart-2.2.3/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/RealmDemoData.java // public class RealmDemoData extends RealmObject { // // private float value; // // private float open, close, high, low; // // private float bubbleSize; // // private RealmList<RealmFloat> stackValues; // // private int xIndex; // // private String xValue; // // private String someStringField; // // // ofc there could me more fields here... // // public RealmDemoData() { // // } // // public RealmDemoData(float value, int xIndex, String xValue) { // this.value = value; // this.xIndex = xIndex; // this.xValue = xValue; // } // // /** // * Constructor for stacked bars. // * // * @param stackValues // * @param xIndex // * @param xValue // */ // public RealmDemoData(float[] stackValues, int xIndex, String xValue) { // this.xIndex = xIndex; // this.xValue = xValue; // this.stackValues = new RealmList<RealmFloat>(); // // for (float val : stackValues) { // this.stackValues.add(new RealmFloat(val)); // } // } // // /** // * Constructor for candles. // * // * @param high // * @param low // * @param open // * @param close // * @param xIndex // */ // public RealmDemoData(float high, float low, float open, float close, int xIndex, String xValue) { // this.value = (high + low) / 2f; // this.high = high; // this.low = low; // this.open = open; // this.close = close; // this.xIndex = xIndex; // this.xValue = xValue; // } // // /** // * Constructor for bubbles. // * // * @param value // * @param xIndex // * @param bubbleSize // * @param xValue // */ // public RealmDemoData(float value, int xIndex, float bubbleSize, String xValue) { // this.value = value; // this.xIndex = xIndex; // this.bubbleSize = bubbleSize; // this.xValue = xValue; // } // // public float getValue() { // return value; // } // // public void setValue(float value) { // this.value = value; // } // // public RealmList<RealmFloat> getStackValues() { // return stackValues; // } // // public void setStackValues(RealmList<RealmFloat> stackValues) { // this.stackValues = stackValues; // } // // public int getxIndex() { // return xIndex; // } // // public void setxIndex(int xIndex) { // this.xIndex = xIndex; // } // // public String getxValue() { // return xValue; // } // // public void setxValue(String xValue) { // this.xValue = xValue; // } // // public float getOpen() { // return open; // } // // public void setOpen(float open) { // this.open = open; // } // // public float getClose() { // return close; // } // // public void setClose(float close) { // this.close = close; // } // // public float getHigh() { // return high; // } // // public void setHigh(float high) { // this.high = high; // } // // public float getLow() { // return low; // } // // public void setLow(float low) { // this.low = low; // } // // public float getBubbleSize() { // return bubbleSize; // } // // public void setBubbleSize(float bubbleSize) { // this.bubbleSize = bubbleSize; // } // // public String getSomeStringField() { // return someStringField; // } // // public void setSomeStringField(String someStringField) { // this.someStringField = someStringField; // } // }
import android.os.Bundle; import android.view.WindowManager; import com.github.mikephil.charting.animation.Easing; import com.github.mikephil.charting.charts.BubbleChart; import com.github.mikephil.charting.data.realm.implementation.RealmBubbleData; import com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet; import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet; import com.github.mikephil.charting.utils.ColorTemplate; import com.xxmassdeveloper.mpchartexample.R; import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData; import java.util.ArrayList; import io.realm.RealmResults;
package com.xxmassdeveloper.mpchartexample.realm; /** * Created by Philipp Jahoda on 21/10/15. */ public class RealmDatabaseActivityBubble extends RealmBaseActivity { private BubbleChart mChart; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_bubblechart_noseekbar); mChart = (BubbleChart) findViewById(R.id.chart1); setup(mChart); mChart.getXAxis().setDrawGridLines(false); mChart.getAxisLeft().setDrawGridLines(false); mChart.setPinchZoom(true); } @Override protected void onResume() { super.onResume(); // setup realm // write some demo-data into the realm.io database writeToDBBubble(10); // add data to the chart setData(); } private void setData() {
// Path: app/libs/MPAndroidChart-2.2.3/MPAndroidChart-2.2.3/MPChartExample/src/com/xxmassdeveloper/mpchartexample/custom/RealmDemoData.java // public class RealmDemoData extends RealmObject { // // private float value; // // private float open, close, high, low; // // private float bubbleSize; // // private RealmList<RealmFloat> stackValues; // // private int xIndex; // // private String xValue; // // private String someStringField; // // // ofc there could me more fields here... // // public RealmDemoData() { // // } // // public RealmDemoData(float value, int xIndex, String xValue) { // this.value = value; // this.xIndex = xIndex; // this.xValue = xValue; // } // // /** // * Constructor for stacked bars. // * // * @param stackValues // * @param xIndex // * @param xValue // */ // public RealmDemoData(float[] stackValues, int xIndex, String xValue) { // this.xIndex = xIndex; // this.xValue = xValue; // this.stackValues = new RealmList<RealmFloat>(); // // for (float val : stackValues) { // this.stackValues.add(new RealmFloat(val)); // } // } // // /** // * Constructor for candles. // * // * @param high // * @param low // * @param open // * @param close // * @param xIndex // */ // public RealmDemoData(float high, float low, float open, float close, int xIndex, String xValue) { // this.value = (high + low) / 2f; // this.high = high; // this.low = low; // this.open = open; // this.close = close; // this.xIndex = xIndex; // this.xValue = xValue; // } // // /** // * Constructor for bubbles. // * // * @param value // * @param xIndex // * @param bubbleSize // * @param xValue // */ // public RealmDemoData(float value, int xIndex, float bubbleSize, String xValue) { // this.value = value; // this.xIndex = xIndex; // this.bubbleSize = bubbleSize; // this.xValue = xValue; // } // // public float getValue() { // return value; // } // // public void setValue(float value) { // this.value = value; // } // // public RealmList<RealmFloat> getStackValues() { // return stackValues; // } // // public void setStackValues(RealmList<RealmFloat> stackValues) { // this.stackValues = stackValues; // } // // public int getxIndex() { // return xIndex; // } // // public void setxIndex(int xIndex) { // this.xIndex = xIndex; // } // // public String getxValue() { // return xValue; // } // // public void setxValue(String xValue) { // this.xValue = xValue; // } // // public float getOpen() { // return open; // } // // public void setOpen(float open) { // this.open = open; // } // // public float getClose() { // return close; // } // // public void setClose(float close) { // this.close = close; // } // // public float getHigh() { // return high; // } // // public void setHigh(float high) { // this.high = high; // } // // public float getLow() { // return low; // } // // public void setLow(float low) { // this.low = low; // } // // public float getBubbleSize() { // return bubbleSize; // } // // public void setBubbleSize(float bubbleSize) { // this.bubbleSize = bubbleSize; // } // // public String getSomeStringField() { // return someStringField; // } // // public void setSomeStringField(String someStringField) { // this.someStringField = someStringField; // } // } // Path: app/libs/MPAndroidChart-2.2.3/MPAndroidChart-2.2.3/MPChartExample/src/com/xxmassdeveloper/mpchartexample/realm/RealmDatabaseActivityBubble.java import android.os.Bundle; import android.view.WindowManager; import com.github.mikephil.charting.animation.Easing; import com.github.mikephil.charting.charts.BubbleChart; import com.github.mikephil.charting.data.realm.implementation.RealmBubbleData; import com.github.mikephil.charting.data.realm.implementation.RealmBubbleDataSet; import com.github.mikephil.charting.interfaces.datasets.IBubbleDataSet; import com.github.mikephil.charting.utils.ColorTemplate; import com.xxmassdeveloper.mpchartexample.R; import com.xxmassdeveloper.mpchartexample.custom.RealmDemoData; import java.util.ArrayList; import io.realm.RealmResults; package com.xxmassdeveloper.mpchartexample.realm; /** * Created by Philipp Jahoda on 21/10/15. */ public class RealmDatabaseActivityBubble extends RealmBaseActivity { private BubbleChart mChart; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_bubblechart_noseekbar); mChart = (BubbleChart) findViewById(R.id.chart1); setup(mChart); mChart.getXAxis().setDrawGridLines(false); mChart.getAxisLeft().setDrawGridLines(false); mChart.setPinchZoom(true); } @Override protected void onResume() { super.onResume(); // setup realm // write some demo-data into the realm.io database writeToDBBubble(10); // add data to the chart setData(); } private void setData() {
RealmResults<RealmDemoData> result = mRealm.allObjects(RealmDemoData.class);