Pierre De Rop | faca289 | 2016-01-31 23:27:05 +0000 | [diff] [blame] | 1 | package org.apache.felix.dm.lambda.callbacks; |
| 2 | |
| 3 | import java.util.Objects; |
| 4 | |
| 5 | /** |
| 6 | * Represents a callback(T param) on an Object instance. |
| 7 | * |
| 8 | * @param T the type of the callback parameter. |
| 9 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a> |
| 10 | */ |
| 11 | @FunctionalInterface |
| 12 | public interface CbConsumer<T> extends SerializableLambda { |
| 13 | /** |
| 14 | * Handles the given argument |
| 15 | * @param t the argument |
| 16 | */ |
| 17 | void accept(T t); |
| 18 | |
| 19 | default CbConsumer<T> andThen(CbConsumer<? super T> after) { |
| 20 | Objects.requireNonNull(after); |
| 21 | return (T t) -> { |
| 22 | accept(t); |
| 23 | after.accept(t); |
| 24 | }; |
| 25 | } |
| 26 | } |