blob: 705533dcbf714a62a43ddeb77ca15d3510467e89 [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) 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 CbTypeComponentService<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 service second callback param
20 */
21 void accept(T instance, Component c, S service);
22
23 default CbTypeComponentService<T, S> andThen(CbTypeComponentService<T, S> after) {
24 Objects.requireNonNull(after);
25 return (T instance, Component c, S s) -> {
26 accept(instance, c, s);
27 after.accept(instance, c, s);
28 };
29 }
30}