com.github.sseserver.util.LambdaUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sse-server Show documentation
Show all versions of sse-server Show documentation
Sse server for Spring Boot
package com.github.sseserver.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
public class LambdaUtil {
public static void sneakyThrows(Throwable t) throws E {
throw (E) t;
}
public static Function noop() {
return o -> o;
}
public static Supplier defaultFalse() {
return () -> Boolean.FALSE;
}
public static Supplier defaultNull() {
return () -> null;
}
public static Supplier defaultZero() {
return () -> 0;
}
public static BiFunction filterNull() {
return (o1, o2) -> o1 != null ? o1 : o2;
}
public static , E> BiFunction reduceList() {
return (o1, o2) -> {
o1.addAll(o2);
return o1;
};
}
public static > Function> distinct() {
return o -> new ArrayList<>(new LinkedHashSet<>(o));
}
}