Pierre De Rop | 1152750 | 2016-02-18 21:07:16 +0000 | [diff] [blame^] | 1 | package org.apache.felix.dm.lambda.callbacks; |
| 2 | |
| 3 | import java.util.Objects; |
| 4 | |
| 5 | /** |
| 6 | * Represents a callback that accepts the result of a CompletableFuture. The callback is invoked on an Object instance. |
| 7 | * |
| 8 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 9 | */ |
| 10 | @FunctionalInterface |
| 11 | public interface InstanceCbFuture<F> { |
| 12 | /** |
| 13 | * Handles the result of a CompletableFuture operation. |
| 14 | * @param future the result of a CompletableFuture operation. |
| 15 | */ |
| 16 | void accept(F future); |
| 17 | |
| 18 | default InstanceCbFuture<F> andThen(InstanceCbFuture<? super F> after) { |
| 19 | Objects.requireNonNull(after); |
| 20 | return (F f) -> { |
| 21 | accept(f); |
| 22 | after.accept(f); |
| 23 | }; |
| 24 | } |
| 25 | } |