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

com.github.andyshao.util.function.ExceptionableToLongFunction 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.ToLongBiFunction;
import java.util.function.ToLongFunction;

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy