blob: c11e1a530322b92e0df9c7c9381286b6f5ee0036 [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;
6import org.osgi.framework.ServiceReference;
7
8/**
9 * Represents a callback(Component, ServiceReference, Service) 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 CbTypeComponentRefService<T, S> extends SerializableLambda {
16 /**
17 * Handles the given arguments.
18 * @param instance the Component implementation instance on which the callback is invoked on.
19 * @param c the first callback parameter
20 * @param ref the second callback parameter
21 * @param service the third callback parameter
22 */
23 void accept(T instance, Component c, ServiceReference<S> ref, S service);
24
25 default CbTypeComponentRefService<T, S> andThen(CbTypeComponentRefService<T, S> after) {
26 Objects.requireNonNull(after);
27 return (T instance, Component c, ServiceReference<S> ref, S service) -> {
28 accept(instance, c, ref, service);
29 after.accept(instance, c, ref, service);
30 };
31 }
32}