blob: 099416d01161baaca03018206dff58c8e158a37c [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.osgi.framework.ServiceReference;
6
7/**
8 * Represents a callback(ServiceReference, 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 CbTypeRefService<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 ref first callback param
19 * @param service second callback param
20 */
21 void accept(T instance, ServiceReference<S> ref, S service);
22
23 default CbTypeRefService<T, S> andThen(CbTypeRefService<? super T, S> after) {
24 Objects.requireNonNull(after);
25 return (T instance, ServiceReference<S> ref, S service) -> {
26 accept(instance, ref, service);
27 after.accept(instance, ref, service);
28 };
29 }
30}