/** * Obtains the {@link Timeout} {@link Duration} in the specified {@link TimeUnit}. * * @param units the desired {@link TimeUnit} * * @return the duration measured in the specified {@link TimeUnit} */ public long to(TimeUnit units) { return duration.to(units); }
/** * Obtains a {@link Duration} for a specific time. * * @param duration the duration for the {@link Duration} * @param units the {@link TimeUnit}s for the duration of the {@link Duration} * * @return the {@link Duration} */ public static Duration of(long duration, TimeUnit units) { return new Duration(duration, units); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof Timeout)) { return false; } Timeout timeout = (Timeout) other; if (!duration.equals(timeout.duration)) { return false; } return true; }
/** * Obtains a randomized version of this {@link RetryFrequency}, where by * values returned from the {@link #get()} {@link Iterable} will be * randomized values between 0 and the values provided by this * {@link RetryFrequency}. * * @return a new randomized {@link RetryFrequency} */ public RetryFrequency randomized() { return new RetryFrequency(() -> new MappingIterator<>(new RandomIterator(new MappingIterator<>(this.get() .iterator(), duration -> duration.to(TimeUnit .MILLISECONDS))), duration -> Duration.of(duration, TimeUnit.MILLISECONDS))); }
/** * Obtains a {@link InitialDelay} for a specific time. * * @param duration the duration for the {@link InitialDelay} * @param units the {@link TimeUnit}s for the duration of the {@link InitialDelay} * * @return the {@link InitialDelay} */ public static InitialDelay of(long duration, TimeUnit units) { return new InitialDelay(Duration.of(duration, units)); }
@Override public int hashCode() { return duration.hashCode(); }
/** * Obtains a randomized version of this {@link RetryFrequency}, where by * values returned from the {@link #get()} {@link Iterable} will be * randomized values between 0 and the values provided by this * {@link RetryFrequency}. * * @return a new randomized {@link RetryFrequency} */ public RetryFrequency randomized() { return new RetryFrequency(() -> new MappingIterator<>(new RandomIterator(new MappingIterator<>(this.get() .iterator(), duration -> duration.to(TimeUnit .MILLISECONDS))), duration -> Duration.of(duration, TimeUnit.MILLISECONDS))); }
/** * Obtains a {@link Timeout} for a specific time. * * @param duration the duration for the {@link Timeout} * @param units the {@link TimeUnit}s for the duration of the {@link Timeout} * * @return the {@link Timeout} */ public static Timeout after(long duration, TimeUnit units) { return new Timeout(Duration.of(duration, units)); }
@Override public int hashCode() { return duration.hashCode(); }
/** * Obtains the {@link MaximumRetryDelay} {@link Duration} in the specified {@link TimeUnit}. * * @param units the desired {@link TimeUnit} * * @return the duration measured in the specified {@link TimeUnit} */ public long to(TimeUnit units) { return duration.to(units); }
/** * Obtains a {@link MaximumRetryDelay} of a specified duration. * * @param duration the duration for the {@link MaximumRetryDelay} * @param units the {@link TimeUnit}s for the duration of the {@link MaximumRetryDelay} * * @return the {@link MaximumRetryDelay} */ public static MaximumRetryDelay of(long duration, TimeUnit units) { return new MaximumRetryDelay(Duration.of(duration, units)); }
@Override public int hashCode() { return duration.hashCode(); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!(other instanceof InitialDelay)) { return false; } InitialDelay timeout = (InitialDelay) other; if (!duration.equals(timeout.duration)) { return false; } return true; }
/** * Obtains a {@link Duration} for a specific time. * * @param duration the duration for the {@link Duration} * @param units the {@link TimeUnit}s for the duration of the {@link Duration} * * @return the {@link Duration} */ public static Duration of(long duration, TimeUnit units) { return new Duration(duration, units); }
/** * Obtains the {@link MaximumRetryDelay} {@link Duration} in the specified {@link TimeUnit}. * * @param units the desired {@link TimeUnit} * * @return the duration measured in the specified {@link TimeUnit} */ public long to(TimeUnit units) { return duration.to(units); }
/** * Obtains a {@link Timeout} for a specific time. * * @param duration the duration for the {@link Timeout} * @param units the {@link TimeUnit}s for the duration of the {@link Timeout} * * @return the {@link Timeout} */ public static Timeout after(long duration, TimeUnit units) { return new Timeout(Duration.of(duration, units)); }