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 | import org.apache.felix.dm.Component; |
| 6 | |
| 7 | /** |
| 8 | * Represents a callback(Component) that is invoked on a Component implementation class. |
| 9 | * The type of the class on which the callback is invoked on is represented by the T generic parameter. |
| 10 | * |
| 11 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 12 | */ |
| 13 | @FunctionalInterface |
| 14 | public interface CbTypeComponent<T> extends SerializableLambda { |
| 15 | /** |
| 16 | * Handles the given arguments |
| 17 | * @param instance the Component implementation instance on which the callback is invoked on. |
| 18 | * @param component the callback parameter |
| 19 | */ |
| 20 | void accept(T instance, Component component); |
| 21 | |
| 22 | default CbTypeComponent<T> andThen(CbTypeComponent<T> after) { |
| 23 | Objects.requireNonNull(after); |
| 24 | return (T instance, Component component) -> { |
| 25 | accept(instance, component); |
| 26 | after.accept(instance, component); |
| 27 | }; |
| 28 | } |
| 29 | } |