public DelayDTO(Delay delay) { if (delay != null) { timeUnit = delay.getTimeUnit(); value = delay.getValue(); } }
@Override public String serialize(int numberOfSpacesToIndent, Delay delay) { StringBuilder output = new StringBuilder(); if (delay != null) { output.append("new Delay(TimeUnit.").append(delay.getTimeUnit().name()).append(", ").append(delay.getValue()).append(")"); } return output.toString(); } }
private Delay addDelays(Delay... delays) { if (delays == null || delays.length == 0) { return null; } else if (delays.length == 1) { return delays[0]; } else if (delays.length == 2 && delays[0] == delays[1]) { return delays[0]; } else { long timeInMilliseconds = 0; for (Delay delay : delays) { if (delay != null) { timeInMilliseconds += delay.getTimeUnit().toMillis(delay.getValue()); } } return new Delay(MILLISECONDS, timeInMilliseconds); } }
public void schedule(Runnable command, boolean synchronous, Delay... delays) { Delay delay = addDelays(delays); if (synchronous) { if (delay != null) { delay.applyDelay(); } command.run(); } else { if (delay != null) { getScheduler().schedule(command, delay.getValue(), delay.getTimeUnit()); } else { command.run(); } } }
public DelayDTO(Delay delay) { if (delay != null) { timeUnit = delay.getTimeUnit(); value = delay.getValue(); } }
@Override public String serialize(int numberOfSpacesToIndent, Delay delay) { StringBuilder output = new StringBuilder(); if (delay != null) { output.append("new Delay(TimeUnit.").append(delay.getTimeUnit().name()).append(", ").append(delay.getValue()).append(")"); } return output.toString(); } }
private Delay addDelays(Delay... delays) { if (delays == null || delays.length == 0) { return null; } else if (delays.length == 1) { return delays[0]; } else if (delays.length == 2 && delays[0] == delays[1]) { return delays[0]; } else { long timeInMilliseconds = 0; for (Delay delay : delays) { if (delay != null) { timeInMilliseconds += delay.getTimeUnit().toMillis(delay.getValue()); } } return new Delay(MILLISECONDS, timeInMilliseconds); } }
public void schedule(Runnable command, boolean synchronous, Delay... delays) { Delay delay = addDelays(delays); if (synchronous) { if (delay != null) { delay.applyDelay(); } command.run(); } else { if (delay != null) { getScheduler().schedule(command, delay.getValue(), delay.getTimeUnit()); } else { command.run(); } } }