com.slimgears.util.stream.Consumers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stream-utils Show documentation
Show all versions of stream-utils Show documentation
General purpose utils / module: stream-utils
package com.slimgears.util.stream;
import java.util.Arrays;
import java.util.function.Consumer;
public class Consumers {
@SafeVarargs
public static T configure(T instance, Consumer... configs) {
return configure(instance, combine(configs));
}
public static T configure(T instance, Consumer config) {
config.accept(instance);
return instance;
}
@SafeVarargs
public static Consumer combine(Consumer... configs) {
return obj -> Arrays.asList(configs).forEach(c -> c.accept(obj));
}
}