blob: bc69d011a2eaf37244a75840546ea3d9516d0161 [file] [log] [blame]
Pierre De Ropfaca2892016-01-31 23:27:05 +00001package org.apache.felix.dm.lambda.callbacks;
2
3import java.util.Dictionary;
4import java.util.Objects;
5
6/**
Pierre De Rop11527502016-02-18 21:07:16 +00007 * Represents a callback(Dictionary) that is invoked on a Component implementation class.
8 * The type of the class on which the callback is invoked on is represented by the T generic parameter.
Pierre De Ropfaca2892016-01-31 23:27:05 +00009 *
10 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
11 */
12@FunctionalInterface
Pierre De Rop11527502016-02-18 21:07:16 +000013public interface CbDictionary<T> extends SerializableLambda {
Pierre De Ropfaca2892016-01-31 23:27:05 +000014 /**
Pierre De Rop11527502016-02-18 21:07:16 +000015 * Handles the given arguments.
16 * @param instance the Component implementation instance on which the callback is invoked on.
17 * @param conf the callback argument
Pierre De Ropfaca2892016-01-31 23:27:05 +000018 */
Pierre De Rop11527502016-02-18 21:07:16 +000019 void accept(T instance, Dictionary<String, Object> conf);
Pierre De Ropfaca2892016-01-31 23:27:05 +000020
Pierre De Rop11527502016-02-18 21:07:16 +000021 default CbDictionary<T> andThen(CbDictionary<? super T> after) {
Pierre De Ropfaca2892016-01-31 23:27:05 +000022 Objects.requireNonNull(after);
Pierre De Rop11527502016-02-18 21:07:16 +000023 return (T instance, Dictionary<String, Object> conf) -> {
24 accept(instance, conf);
25 after.accept(instance, conf);
Pierre De Ropfaca2892016-01-31 23:27:05 +000026 };
27 }
28}