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

com.github.andyshao.util.function.ExceptionableSupplier Maven / Gradle / Ivy

The newest version!
package com.github.andyshao.util.function;

import com.github.andyshao.lang.Convert;
import com.github.andyshao.util.stream.RuntimeExceptionFactory;

import java.util.function.Supplier;

/**
 * 
 * 
 * Title:
* Descript:
* Copyright: Copryright(c) Jun 5, 2019
* Encoding: UNIX UTF-8 * * @author Andy.Shao * * @param return type * @see Supplier */ @FunctionalInterface public interface ExceptionableSupplier { /** * get operation * @return the value * @throws Throwable any error */ R get() throws Throwable; /** * to supplier * @param f exception factory * @return {@link Supplier} * @param data type */ static Convert, Supplier> toSupplier(RuntimeExceptionFactory f) { return input -> { return () -> { try { return input.get(); } catch (Throwable e) { throw f.build(e); } }; }; } /** * to supplier * @return {@link Supplier} * @param data type */ static Convert, Supplier> toSupplier() { return toSupplier(RuntimeExceptionFactory.DEFAULT); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy