blob: 1f5077b792095717589f8f02e59e52025c874b96 [file] [log] [blame]
Pierre De Rop11527502016-02-18 21:07:16 +00001package org.apache.felix.dm.lambda.callbacks;
2
3import 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
13public 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}