org.davidmoten.kool.function.Function Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kool Show documentation
Show all versions of kool Show documentation
Streaming library supporting reuse and many operators
package org.davidmoten.kool.function;
import org.davidmoten.kool.internal.util.Exceptions;
import org.davidmoten.kool.internal.util.StreamUtils;
@FunctionalInterface
public interface Function {
R apply(T t) throws Exception;
default R applyUnchecked(T t) {
try {
return apply(t);
} catch (Exception e) {
return Exceptions.rethrow(e);
}
}
@SuppressWarnings("unchecked")
public static Function identity() {
return (Function) StreamUtils.FunctionIdentityHolder.IDENTITY;
}
}