blob: d48a9bba1099207a20c95785aa01f536032441cb [file] [log] [blame]
Pierre De Rop11527502016-02-18 21:07:16 +00001package org.apache.felix.dm.lambda.callbacks;
2
3import java.util.Objects;
4
5import org.apache.felix.dm.Component;
6
7/**
8 * Represents a swap callback(Service, Service, Component) on an Object instance.
9 *
10 * <p> The type of the service passed in argument to the callback is defined by the "S" generic parameter.
11 *
12 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
13 */
14@FunctionalInterface
15public interface InstanceCbServiceServiceComponent<S> extends SerializableLambda {
16 /**
17 * Handles the given arguments.
18 * @param c the component
19 * @param old the old service
20 * @param replace the new service
21 */
22 void accept(S old, S replace, Component c);
23
24 default InstanceCbServiceServiceComponent<S> andThen(InstanceCbServiceServiceComponent<S> after) {
25 Objects.requireNonNull(after);
26 return (S old, S replace, Component c) -> {
27 accept(old, replace, c);
28 after.accept(old, replace, c);
29 };
30 }
31}