/** * {@inheritDoc} */ @Override public String toString() { return String.format("Ensured{%s}", getDeferredClass(), getDeferred()); } }
/** * Construct an {@link Ensured} adapting the specified {@link Deferred}. * * @param deferred the {@link Deferred} to adapt * @param retryDurationsMS an {@link Iterator} providing individual retry * durations (in milliseconds) for each time the * {@link Ensured} needs to wait * @param totalDurationMS the maximum duration (in milliseconds) to wait * for the {@link Deferred} to become available */ public Ensured(Deferred<T> deferred, Iterator<Long> retryDurationsMS, long totalDurationMS) { // when we're ensuring an ensured, use the adapted deferred // (this is to ensure that we don't attempt to ensure another ensured) m_deferred = deferred instanceof Ensured ? ((Ensured<T>) deferred).getDeferred() : deferred; m_retryDurationsMS = retryDurationsMS; m_totalDurationMS = totalDurationMS < 0 ? 0 : totalDurationMS; }