1 /* 2 * Copyright 2018 SPF4J. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.spf4j.failsafe; 17 18 import java.util.concurrent.Callable; 19 import java.util.function.BiFunction; 20 import javax.annotation.Nonnull; 21 import javax.annotation.Nullable; 22 23 /** 24 * Chainable Result predicate. 25 * This predicate will not return a RetryDecision (null) when if want to deffer the retry decision. 26 * @author Zoltan Farkas 27 */ 28 @FunctionalInterface 29 public interface PartialResultRetryPredicate<T, C extends Callable<? extends T>> 30 extends BiFunction<T, C, RetryDecision<T, C>> { 31 32 @Nullable 33 RetryDecision<T, C> getDecision(@Nonnull T value, @Nonnull C what); 34 35 @Override 36 @Nullable 37 default RetryDecision<T, C> apply(final T t, final C u) { 38 return getDecision(t, u); 39 } 40 41 }