/** * Constructs a local {@link TransportAddress} for the specified port. * * @param port the port */ public TransportAddress(int port) { this(null, new Capture<>(new PerpetualIterator<>(port))); }
@Override public Iterator<Duration> iterator() { return new MappingIterator<Long, Duration>(new RandomIterator(new ExponentialIterator(0, 50)), MILLISECONDS_TO_DURATION); } };
/** * Obtains the {@link InitialDelay} {@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); }
/** * Constructs a {@link RandomIterator} for numbers between * 0 and the specified range (exclusive). * * @param range the upper bound of the range */ public RandomIterator(long range) { this(new PerpetualIterator<Long>(range)); }
/** * Obtains a {@link RetryFrequency} based on the Fibonacci sequence. * * @return a {@link RetryFrequency} */ public static RetryFrequency fibonacci() { return new RetryFrequency(() -> new MappingIterator<>(new FibonacciIterator(), duration -> Duration.of(duration, TimeUnit.MILLISECONDS))); }
/** * Constructs a {@link Version} by parsing the specified components of a version number. * If a component string itself contains components, those are parsed and included in the {@link Version}. * * @param strings the components of the {@link Version} number * * @return a {@link Version} */ public static Version of(String... strings) { return new Version(strings); }
@Override public Iterator<Duration> iterator() { return new MappingIterator<Long, Duration>(new FibonacciIterator(), MILLISECONDS_TO_DURATION); } };
@Override public int hashCode() { return duration.hashCode(); }
/** * Obtains the captured value. Should a value not be captured, * {@link #next()} is invoked to capture a value. * * @return the captured value */ public T get() { return next(); }
/** * Constructs a {@link TransportAddress} with the specified port. * * @param address the address * @param port the port */ public TransportAddress(InetAddress address, int port) { this(address, new Capture<>(new PerpetualIterator<>(port))); }
/** * Constructs a {@link RandomIterator} for numbers between * 0 and the specified range (exclusive). * * @param range the upper bound of the range */ public RandomIterator(long range) { this(new PerpetualIterator<Long>(range)); }
/** * Obtains a {@link RetryFrequency} based on the Fibonacci sequence. * * @return a {@link RetryFrequency} */ public static RetryFrequency fibonacci() { return new RetryFrequency(() -> new MappingIterator<>(new FibonacciIterator(), duration -> Duration.of(duration, TimeUnit.MILLISECONDS))); }
/** * 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); }
@Override public Iterator<Duration> iterator() { return new MappingIterator<Long, Duration>(new RandomIterator(new ExponentialIterator(0, 50)), MILLISECONDS_TO_DURATION); } };
/** * Construct a {@link Version} representing an unknown version number. * * @return an unknown {@link Version} */ public static Version unknown() { return new Version("unknown"); }
/** * Constructs a {@link TransportAddress} with the specified port. * * @param address the address * @param port the port */ public TransportAddress(InetAddress address, int port) { this(address, new Capture<>(new PerpetualIterator<>(port))); }
/** * Constructs a {@link Version} by parsing the specified components of a version number. * If a component string itself contains components, those are parsed and included in the {@link Version}. * * @param strings the components of the {@link Version} number * * @return a {@link Version} */ public static Version of(String... strings) { return new Version(strings); }
/** * Constructs a local {@link TransportAddress} for the specified port. * * @param port the port */ public TransportAddress(int port) { this(null, new Capture<>(new PerpetualIterator<>(port))); }
/** * Constructs a local {@link ListenAddress} for the specified port. * * @param port the port */ public ListenAddress(int port) { this(null, new Capture<>(new PerpetualIterator<>(port))); }
/** * Constructs a {@link ListenAddress} with the specified port. * * @param address the address * @param port the port */ public ListenAddress(InetAddress address, int port) { this(address, new Capture<>(new PerpetualIterator<>(port))); }