
com.aggrepoint.utils.LambdaUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aputils Show documentation
Show all versions of aputils Show documentation
Common utilities used by both Dao and Winlet project
The newest version!
package com.aggrepoint.utils;
import java.util.function.Consumer;
import java.util.function.Function;
public class LambdaUtils {
public static void consumeIfNotNull(T val, Consumer consumer) {
if (val != null)
consumer.accept(val);
}
public static R ifNotNull(T val, Function func) {
if (val != null)
return func.apply(val);
return null;
}
/**
* 将val分发给consumers
*/
@SafeVarargs
public static T pass(T val, Consumer... consumers) {
if (consumers != null)
for (Consumer c : consumers)
c.accept(val);
return val;
}
/**
* 将val分发给consumer
*/
public static T pass(T val, Consumer consumer) {
if (consumer != null)
consumer.accept(val);
return val;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy