| Modifier and Type | Method and Description |
|---|---|
static <T> SmartSupplier<T> |
forSupplier(Supplier<T> wrappedSupplier)
create smart supplier
|
T |
get() |
static <T> T |
supplyPeriodically(Supplier<T> supplier,
int attemptCount,
int waitTimeValue,
TimeUnit waitTimeUnit)
get value from
Supplier with multiple attempts |
static <T> T |
supplyPeriodicallyOrDefault(Supplier<T> supplier,
int attemptCount,
int waitTimeValue,
TimeUnit waitTimeUnit,
T defaultValue)
get value from
Supplier with multiple attempts |
SmartSupplier<T> |
useCacheAfterFailedAttemptsCount(int failedAttemptCount)
instruct to use cached value (if exists) after x times the wrapped supplier returns null-value
|
SmartSupplier<T> |
withAttemptCount(int attemptCount)
instruct smart supplier to retry
Supplier.get() multiple time, if wrapped supplier returns null-value |
SmartSupplier<T> |
withCacheExpireTime(int cacheExpireTimeValue,
TimeUnit cacheExpireTimeUnit)
define expire time for cached value
|
SmartSupplier<T> |
withDefaultValue(T defaultValue)
define default value, if supplier return no not-null-value
|
SmartSupplier<T> |
withWaitTimeForNextAttempt(int waitTimeValue,
TimeUnit waitTimeUnit)
define wait time for next retry - @see
withAttemptCount(int) |
public static <T> SmartSupplier<T> forSupplier(Supplier<T> wrappedSupplier)
wrappedSupplier - wrapped supplierpublic SmartSupplier<T> withAttemptCount(int attemptCount)
Supplier.get() multiple time, if wrapped supplier returns null-valueattemptCount - counts to attemptpublic SmartSupplier<T> withWaitTimeForNextAttempt(int waitTimeValue, TimeUnit waitTimeUnit)
withAttemptCount(int)waitTimeValue - wait time until next attempt to get next valuewaitTimeUnit - wait time unit until next attempt to get next valuepublic SmartSupplier<T> withDefaultValue(T defaultValue)
defaultValue - value to supply, if wrapped supplier return no not-null-valuepublic SmartSupplier<T> useCacheAfterFailedAttemptsCount(int failedAttemptCount)
failedAttemptCount - how often wrapped supplier returns null-value until cached value will returnspublic SmartSupplier<T> withCacheExpireTime(int cacheExpireTimeValue, TimeUnit cacheExpireTimeUnit)
cacheExpireTimeValue - expire time value for cached valuecacheExpireTimeUnit - expire time unit for cached valuepublic static <T> T supplyPeriodicallyOrDefault(Supplier<T> supplier, int attemptCount, int waitTimeValue, TimeUnit waitTimeUnit, T defaultValue)
Supplier with multiple attemptssupplier - wrapped supplierattemptCount - count of attemptswaitTimeValue - wait time until next attempt to get next valuewaitTimeUnit - wait time unit until next attempt to get next valuedefaultValue - value to return, if supplier supplies no valuepublic static <T> T supplyPeriodically(Supplier<T> supplier, int attemptCount, int waitTimeValue, TimeUnit waitTimeUnit)
Supplier with multiple attemptssupplier - wrapped supplierattemptCount - count of attemptswaitTimeValue - wait time until next attempt to get next valuewaitTimeUnit - wait time unit until next attempt to get next valueCopyright © 2020. All rights reserved.