com.softicar.platform.common.core.retry.RetryingSupplier Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.core.retry;
import java.util.function.Supplier;
/**
* Utility class to retry the execution of a {@link Supplier}.
*
* @author Oliver Richers
*/
public class RetryingSupplier extends AbstractRetrier> implements Supplier {
private final Supplier supplier;
private T result;
public RetryingSupplier(Supplier supplier) {
this.supplier = supplier;
}
/**
* Starts the execution of the retry loop and returns the result.
*/
@Override
public T get() {
executeRetryLoop();
return result;
}
@Override
protected void executeTry() {
this.result = supplier.get();
}
@Override
protected RetryingSupplier getThis() {
return this;
}
}