List of usage examples for java.util.function ToLongBiFunction applyAsLong
long applyAsLong(T t, U u);
From source file:Main.java
public static void main(String[] args) { ToLongBiFunction<String, String> i = (x, y) -> Long.parseLong(x) + Long.parseLong(y); System.out.println(i.applyAsLong("2", "2")); }
From source file:at.gridtec.lambda4j.function.bi.to.ToLongBiFunction2.java
/** * Calls the given {@link ToLongBiFunction} with the given arguments and returns its result. * * @param <T> The type of the first argument to the function * @param <U> The type of the second argument to the function * @param function The function to be called * @param t The first argument to the function * @param u The second argument to the function * @return The result from the given {@code ToLongBiFunction2}. * @throws NullPointerException If given argument is {@code null} *//* w ww. j av a2 s . c o m*/ static <T, U> long call(@Nonnull final ToLongBiFunction<? super T, ? super U> function, T t, U u) { Objects.requireNonNull(function); return function.applyAsLong(t, u); }
From source file:at.gridtec.lambda4j.function.bi.to.ThrowableToLongBiFunction.java
/** * Returns a composed {@link ToLongBiFunction2} that first applies this function to its input, and then applies the * {@code recover} operation if a {@link Throwable} is thrown from this one. The {@code recover} operation is * represented by a curried operation which is called with throwable information and same arguments of this * function./*from w w w . ja v a 2s .c om*/ * * @param recover The operation to apply if this function throws a {@code Throwable} * @return A composed {@link ToLongBiFunction2} that first applies this function to its input, and then applies the * {@code recover} operation if a {@code Throwable} is thrown from this one. * @throws NullPointerException If given argument or the returned enclosing function is {@code null} * @implSpec The implementation checks that the returned enclosing function from {@code recover} operation is not * {@code null}. If it is, then a {@link NullPointerException} with appropriate message is thrown. * @implNote If thrown {@code Throwable} is of type {@link Error}, it is thrown as-is and thus not passed to {@code * recover} operation. */ @Nonnull default ToLongBiFunction2<T, U> recover( @Nonnull final Function<? super Throwable, ? extends ToLongBiFunction<? super T, ? super U>> recover) { Objects.requireNonNull(recover); return (t, u) -> { try { return this.applyAsLongThrows(t, u); } catch (Error e) { throw e; } catch (Throwable throwable) { final ToLongBiFunction<? super T, ? super U> function = recover.apply(throwable); Objects.requireNonNull(function, () -> "recover returned null for " + throwable.getClass() + ": " + throwable.getMessage()); return function.applyAsLong(t, u); } }; }