blob: 3e44ac6f11989b130e8b85bed0e12c5001df494e [file] [log] [blame]
Pierre De Rop11527502016-02-18 21:07:16 +00001package org.apache.felix.dm.lambda.callbacks;
2
3import java.util.Objects;
4
5/**
6 * Represents a java8 method reference to a zero-argument method from a given component implementation class.
7 * <p> The type of the class on which the callback is invoked on is represented by the T generic parameter.
8 * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
9 */
10@FunctionalInterface
11public interface Cb<T> extends SerializableLambda {
12 /**
13 * Invokes the callback method on the given component implementation instance.
14 * @param t the component implementation instance the callback is invoked on.
15 */
16 void accept(T t);
17
18 default Cb<T> andThen(Cb<? super T> after) {
19 Objects.requireNonNull(after);
20 return (T t) -> {
21 accept(t);
22 after.accept(t);
23 };
24 }
25}