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, 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 CbTypeServiceService<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 old first callback param |
| 17 | * @param replace second callback param |
| 18 | */ |
| 19 | void accept(T instance, S old, S replace); |
| 20 | |
| 21 | default CbTypeServiceService<T, S> andThen(CbTypeServiceService<? super T, S> after) { |
| 22 | Objects.requireNonNull(after); |
| 23 | return (T instance, S old, S replace) -> { |
| 24 | accept(instance, old, replace); |
| 25 | after.accept(instance, old, replace); |
| 26 | }; |
| 27 | } |
| 28 | } |