com.github.phantomthief.util.ThrowableFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of more-lambdas Show documentation
Show all versions of more-lambdas Show documentation
Some useful lambda implements for Java 8.
package com.github.phantomthief.util;
import static java.util.Objects.requireNonNull;
/**
* @author w.vela
*/
@FunctionalInterface
public interface ThrowableFunction {
static ThrowableFunction identity() {
return t -> t;
}
R apply(T t) throws X;
default ThrowableFunction
compose(ThrowableFunction super V, ? extends T, X> before) {
requireNonNull(before);
return (V v) -> apply(before.apply(v));
}
default ThrowableFunction
andThen(ThrowableFunction super R, ? extends V, X> after) {
requireNonNull(after);
return (T t) -> after.apply(apply(t));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy