All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.phantomthief.failover.impl.GenericRecoverableCheckFailoverBuilder Maven / Gradle / Ivy

package com.github.phantomthief.failover.impl;

import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;

import javax.annotation.CheckReturnValue;

/**
 * @author w.vela
 */
public class GenericRecoverableCheckFailoverBuilder {

    private final RecoverableCheckFailoverBuilder builder;

    GenericRecoverableCheckFailoverBuilder(RecoverableCheckFailoverBuilder builder) {
        this.builder = builder;
    }

    @CheckReturnValue
    public RecoverableCheckFailoverBuilder setFailCount(int failCount) {
        return builder.setFailCount(failCount);
    }

    @CheckReturnValue
    public GenericRecoverableCheckFailoverBuilder setChecker(Predicate checker) {
        builder.setChecker(checker);
        return this;
    }

    @CheckReturnValue
    public GenericRecoverableCheckFailoverBuilder
            setRecoveryCheckDuration(long recoveryCheckDuration, TimeUnit unit) {
        builder.setRecoveryCheckDuration(recoveryCheckDuration, unit);
        return this;
    }

    @CheckReturnValue
    public GenericRecoverableCheckFailoverBuilder setFailDuration(long failDuration,
            TimeUnit unit) {
        builder.setFailDuration(failDuration, unit);
        return this;
    }

    @CheckReturnValue
    public GenericRecoverableCheckFailoverBuilder
            setReturnOriginalWhileAllFailed(boolean returnOriginalWhileAllFailed) {
        builder.setReturnOriginalWhileAllFailed(returnOriginalWhileAllFailed);
        return this;
    }

    public RecoverableCheckFailover build(List original) {
        return builder.build(original);
    }
}