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 swap callback(Service, Service) on an Object instance. |
| 7 | * |
| 8 | * <p> The type of the service passed in argument to the callback is defined by the "S" generic parameter. |
| 9 | * |
| 10 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 11 | */ |
| 12 | @FunctionalInterface |
| 13 | public interface InstanceCbServiceService<S> extends SerializableLambda { |
| 14 | /** |
| 15 | * Handles the given argument |
| 16 | * @param old a Service |
| 17 | * @param replace a Service |
| 18 | */ |
| 19 | void accept(S old, S replace); |
| 20 | |
| 21 | default InstanceCbServiceService<S> andThen(InstanceCbServiceService<S> after) { |
| 22 | Objects.requireNonNull(after); |
| 23 | return (S old, S replace) -> { |
| 24 | accept(old, replace); |
| 25 | after.accept(old, replace); |
| 26 | }; |
| 27 | } |
| 28 | } |