public int compareTo(Duration other) { if (other == null) return 1; long x = getValueInMS(); long y = other.getValueInMS(); return (x < y) ? -1 : ((x == y) ? 0 : 1); }
/** * Converts from {@code org.awaitility.Duration} to {@link java.time.Duration}. * * @param duration a {@code org.awaitility.Duration} to convert to {@code java.time.Duration} * * @return the {@code java.time.Duration} value of duration */ public static java.time.Duration toTimeDuration(Duration duration) { return ofMillis(duration.getValueInMS()); } }
/** * {@inheritDoc} */ @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Duration duration = (Duration) o; return getValueInMS() == duration.getValueInMS(); }
private long getRemainingTimeInMS(long elapsedTimeInMS, Duration maxWaitTime) { return maxWaitTime.equals(Duration.FOREVER) ? Long.MAX_VALUE : maxWaitTime.getValueInMS() - elapsedTimeInMS; }
final long timeoutInMS = timeout.getValueInMS(); if (!timeout.isForever() && timeoutInMS <= actualPollDelay.getValueInMS()) { throw new IllegalStateException(String.format("Timeout (%s %s) must be greater than the poll delay (%s %s).", timeout.getValue(), timeout.getTimeUnitAsString(), actualPollDelay.getValue(), actualPollDelay.getTimeUnitAsString())); } else if ((!actualPollDelay.isForever() && !timeout.isForever()) && timeoutInMS <= actualPollDelay.getValueInMS()) { throw new IllegalStateException(String.format("Timeout (%s %s) must be greater than the poll delay (%s %s).", timeout.getValue(), timeout.getTimeUnitAsString(), actualPollDelay.getValue(), actualPollDelay.getTimeUnitAsString()));
public int compareTo(Duration other) { if (other == null) return 1; long x = getValueInMS(); long y = other.getValueInMS(); return (x < y) ? -1 : ((x == y) ? 0 : 1); }
Thread.sleep(pollDelay.getValueInMS()); Thread.sleep(pollInterval.getValueInMS()); evaluationDuration = calculateConditionEvaluationDuration(pollDelay, pollingStartedNanos);
/** * {@inheritDoc} */ @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Duration duration = (Duration) o; return getValueInMS() == duration.getValueInMS(); }
private long getRemainingTimeInMS(long elapsedTimeInMS, Duration maxWaitTime) { return maxWaitTime.equals(Duration.FOREVER) ? Long.MAX_VALUE : maxWaitTime.getValueInMS() - elapsedTimeInMS; }
final long timeoutInMS = timeout.getValueInMS(); if (!timeout.isForever() && timeoutInMS <= actualPollDelay.getValueInMS()) { throw new IllegalStateException(String.format("Timeout (%s %s) must be greater than the poll delay (%s %s).", timeout.getValue(), timeout.getTimeUnitAsString(), actualPollDelay.getValue(), actualPollDelay.getTimeUnitAsString())); } else if ((!actualPollDelay.isForever() && !timeout.isForever()) && timeoutInMS <= actualPollDelay.getValueInMS()) { throw new IllegalStateException(String.format("Timeout (%s %s) must be greater than the poll delay (%s %s).", timeout.getValue(), timeout.getTimeUnitAsString(), actualPollDelay.getValue(), actualPollDelay.getTimeUnitAsString()));
Thread.sleep(pollDelay.getValueInMS()); Thread.sleep(pollInterval.getValueInMS()); evaluationDuration = calculateConditionEvaluationDuration(pollDelay, pollingStartedNanos);