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