blob: 54b0d723c59f9a2e2dc51cb3f1fbb404ca8bf414 [file] [log] [blame]
Pierre De Ropfaca2892016-01-31 23:27:05 +00001package org.apache.felix.dm.lambda.callbacks;
2
3import java.util.Objects;
4
5/**
6 * Represents a callback that accepts the result of a CompletableFuture operation. The callback is invoked on a Component implementation class.
7 * The type of the class on which the callback is invoked on is represented by the T generic parameter.
8 * The type of the result of the CompletableFuture is represented by the F generic parameter.
9 *
10 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
11 */
12@FunctionalInterface
13public interface CbTypeFuture<T, F> extends SerializableLambda {
14 /**
15 * Handles the given arguments.
16 * @param instance the Component implementation instance on which the callback is invoked on.
17 * @param future the result of a CompletableFuture operation.
18 */
19 void accept(T instance, F future);
20
21 default CbTypeFuture<T, F> andThen(CbTypeFuture<? super T, F> after) {
22 Objects.requireNonNull(after);
23 return (T instance, F future) -> {
24 accept(instance, future);
25 after.accept(instance, future);
26 };
27 }
28}