blob: 58befd1df63867b4ad001ceafd5b08cf1af378b1 [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;
6import org.osgi.framework.Bundle;
7
8/**
9 * Represents a callback(Bundle, Component) that is invoked on a Component implementation class.
10 * The type of the class on which the callback is invoked on is represented by the T generic parameter.
11 *
12 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
13 */
14@FunctionalInterface
15public interface CbBundleComponent<T> extends SerializableLambda {
16 /**
17 * Handles the given arguments.
18 * @param instance the Component implementation instance on which the callback is invoked on.
19 * @param bundle the first callback parameter
20 * @param component the second callback parameter
21 */
22 void accept(T instance, Bundle bundle, Component component);
23
24 default CbBundleComponent<T> andThen(CbBundleComponent<? super T> after) {
25 Objects.requireNonNull(after);
26 return (T instance, Bundle bundle, Component component) -> {
27 accept(instance, bundle, component);
28 after.accept(instance, bundle, component);
29 };
30 }
31}