Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 1 | package org.apache.felix.dm.lambda.callbacks; |
| 2 | |
| 3 | import java.util.Objects; |
| 4 | |
| 5 | /** |
| 6 | * Represents a callback(Service) that 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 | * |
| 9 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 10 | */ |
| 11 | @FunctionalInterface |
| 12 | public interface CbTypeService<T, S> extends SerializableLambda { |
| 13 | /** |
| 14 | * Handles the given arguments. |
| 15 | * @param instance the Component implementation instance on which the callback is invoked on. |
| 16 | * @param service first callback param |
| 17 | */ |
| 18 | void accept(T instance, S service); |
| 19 | |
| 20 | default CbTypeFuture<T, S> andThen(CbTypeFuture<? super T, S> after) { |
| 21 | Objects.requireNonNull(after); |
| 22 | return (T instance, S service) -> { |
| 23 | accept(instance, service); |
| 24 | after.accept(instance, service); |
| 25 | }; |
| 26 | } |
| 27 | } |