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

com.github.andyshao.util.function.ExceptionableToDoubleFunction 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.ToDoubleFunction;

/**
 * 
 * Title:
* Descript:
* Copyright: Copryright(c) Jun 14, 2019
* Encoding: UNIX UTF-8 * * @author Andy.Shao * * @param argument type * @see ToDoubleFunction */ public interface ExceptionableToDoubleFunction { /** * apply as {@link Double} * @param value input * @return double value * @throws Throwable any error */ double applyAsDouble(T value) throws Throwable; /** * to double function * @param f exception function * @return {@link ToDoubleFunction} * @param data type */ static Convert, ToDoubleFunction> toDoubleFunction(RuntimeExceptionFactory f) { return input -> { return t -> { try { return input.applyAsDouble(t); } catch (Throwable e) { throw f.build(e); } }; }; } /** * to double function * @return {@link ToDoubleFunction} * @param data type */ static Convert, ToDoubleFunction> toDoubleFunction() { return toDoubleFunction(RuntimeExceptionFactory.DEFAULT); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy