All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.phantomthief.util.ThrowableFunction Maven / Gradle / Ivy

There is a newer version: 0.1.55
Show newest version
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 before) {
        requireNonNull(before);
        return (V v) -> apply(before.apply(v));
    }

    default  ThrowableFunction
            andThen(ThrowableFunction after) {
        requireNonNull(after);
        return (T t) -> after.apply(apply(t));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy