blob: d234a915c2bbb4b5468cc826ee067bc329dcbb3f [file] [log] [blame]
Pierre De Ropfaca2892016-01-31 23:27:05 +00001package org.apache.felix.dm.lambda.callbacks;
2
3import java.util.Objects;
4
5import org.apache.felix.dm.Component;
6
7/**
8 * Represents a callback(Component, Service, Service) that is invoked on a Component implementation class.
9 * The type of the class on which the callback is invoked on is represented by the T generic parameter.
10 *
11 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
12 */
13@FunctionalInterface
14public interface CbTypeComponentServiceService<T, S> extends SerializableLambda {
15 /**
16 * Handles the given arguments.
17 * @param instance the Component implementation instance on which the callback is invoked on.
18 * @param c first callback param
19 * @param old second callback param
20 * @param replace third callback param
21 */
22 void accept(T instance, Component c, S old, S replace);
23
24 default CbTypeComponentServiceService<T, S> andThen(CbTypeComponentServiceService<? super T, S> after) {
25 Objects.requireNonNull(after);
26 return (T instance, Component c, S old, S replace) -> {
27 accept(instance, c, old, replace);
28 after.accept(instance, c, old, replace);
29 };
30 }
31}