io.datakernel.util.Initializer Maven / Gradle / Ivy
package io.datakernel.util;
import java.util.List;
import static java.util.Arrays.asList;
@FunctionalInterface
public interface Initializer> {
void accept(T t);
default Initializer andThen(Initializer super T> next) {
return t -> {
this.accept(t);
next.accept(t);
};
}
static > Initializer empty() {
return $ -> {};
}
static > Initializer combine(List extends Initializer super T>> initializers) {
return target -> initializers.forEach(initializer -> initializer.accept(target));
}
@SafeVarargs
static > Initializer combine(Initializer super T>... initializers) {
return combine(asList(initializers));
}
}