blob: 9bed1bd60cd7881ecadb398877750d27c6bf4d2c [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) 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 CbTypeComponent<T> extends SerializableLambda {
15 /**
16 * Handles the given arguments
17 * @param instance the Component implementation instance on which the callback is invoked on.
18 * @param component the callback parameter
19 */
20 void accept(T instance, Component component);
21
22 default CbTypeComponent<T> andThen(CbTypeComponent<T> after) {
23 Objects.requireNonNull(after);
24 return (T instance, Component component) -> {
25 accept(instance, component);
26 after.accept(instance, component);
27 };
28 }
29}