blob: 509cdc475ebcf55a4095829d437bab01036a33da [file] [log] [blame]
Pierre De Ropfaca2892016-01-31 23:27:05 +00001package org.apache.felix.dm.lambda.callbacks;
2
3import java.util.Map;
4import java.util.Objects;
5
6import org.apache.felix.dm.Component;
7
8/**
9 * Represents a callback(Component, ServiceReference, Service, Service Reference, 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 CbTypeComponentServiceMap<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 first callback param
20 * @param service second callback param
21 * @param props third callback param
22 */
23 void accept(T instance, Component c, S service, Map<String, Object> props);
24
25 default CbTypeComponentServiceMap<T, S> andThen(CbTypeComponentServiceMap<T, S> after) {
26 Objects.requireNonNull(after);
27 return (T instance, Component c, S s, Map<String, Object> props) -> {
28 accept(instance, c, s, props);
29 after.accept(instance, c, s, props);
30 };
31 }
32}