Example usage for java.util.function ToLongFunction applyAsLong

List of usage examples for java.util.function ToLongFunction applyAsLong

Introduction

In this page you can find the example usage for java.util.function ToLongFunction applyAsLong.

Prototype

long applyAsLong(T value);

Source Link

Document

Applies this function to the given argument.

Usage

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjFloatToLongFunction.java

/**
 * Creates a {@link BiObjFloatToLongFunction} which uses the {@code first} parameter of this one as argument for the
 * given {@link ToLongFunction}./*from   www. j a va 2  s.  c o  m*/
 *
 * @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 which accepts the {@code first} parameter of this one
 * @return Creates a {@code BiObjFloatToLongFunction} which uses the {@code first} parameter of this one as argument
 * for the given {@code ToLongFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiObjFloatToLongFunction<T, U> onlyFirst(@Nonnull final ToLongFunction<? super T> function) {
    Objects.requireNonNull(function);
    return (t, u, value) -> function.applyAsLong(t);
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjFloatToLongFunction.java

/**
 * Creates a {@link BiObjFloatToLongFunction} which uses the {@code second} parameter of this one as argument for
 * the given {@link ToLongFunction}.//from w w w  .  j  a  v  a 2  s .c o m
 *
 * @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 which accepts the {@code second} parameter of this one
 * @return Creates a {@code BiObjFloatToLongFunction} which uses the {@code second} parameter of this one as
 * argument for the given {@code ToLongFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiObjFloatToLongFunction<T, U> onlySecond(@Nonnull final ToLongFunction<? super U> function) {
    Objects.requireNonNull(function);
    return (t, u, value) -> function.applyAsLong(u);
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjShortToLongFunction.java

/**
 * Creates a {@link BiObjShortToLongFunction} which uses the {@code first} parameter of this one as argument for the
 * given {@link ToLongFunction}./*from  ww w  .java2  s . co  m*/
 *
 * @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 which accepts the {@code first} parameter of this one
 * @return Creates a {@code BiObjShortToLongFunction} which uses the {@code first} parameter of this one as argument
 * for the given {@code ToLongFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiObjShortToLongFunction<T, U> onlyFirst(@Nonnull final ToLongFunction<? super T> function) {
    Objects.requireNonNull(function);
    return (t, u, value) -> function.applyAsLong(t);
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjShortToLongFunction.java

/**
 * Creates a {@link BiObjShortToLongFunction} which uses the {@code second} parameter of this one as argument for
 * the given {@link ToLongFunction}.//from  w w  w  .  j  a v a 2 s. c  om
 *
 * @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 which accepts the {@code second} parameter of this one
 * @return Creates a {@code BiObjShortToLongFunction} which uses the {@code second} parameter of this one as
 * argument for the given {@code ToLongFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiObjShortToLongFunction<T, U> onlySecond(@Nonnull final ToLongFunction<? super U> function) {
    Objects.requireNonNull(function);
    return (t, u, value) -> function.applyAsLong(u);
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjIntToLongFunction.java

/**
 * Creates a {@link BiObjIntToLongFunction} which uses the {@code first} parameter of this one as argument for the
 * given {@link ToLongFunction}./*  w  w w.j  a v  a 2  s.co m*/
 *
 * @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 which accepts the {@code first} parameter of this one
 * @return Creates a {@code BiObjIntToLongFunction} which uses the {@code first} parameter of this one as argument
 * for the given {@code ToLongFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiObjIntToLongFunction<T, U> onlyFirst(@Nonnull final ToLongFunction<? super T> function) {
    Objects.requireNonNull(function);
    return (t, u, value) -> function.applyAsLong(t);
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjIntToLongFunction.java

/**
 * Creates a {@link BiObjIntToLongFunction} which uses the {@code second} parameter of this one as argument for the
 * given {@link ToLongFunction}./*w  w w .ja  va  2 s.c o  m*/
 *
 * @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 which accepts the {@code second} parameter of this one
 * @return Creates a {@code BiObjIntToLongFunction} which uses the {@code second} parameter of this one as argument
 * for the given {@code ToLongFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiObjIntToLongFunction<T, U> onlySecond(@Nonnull final ToLongFunction<? super U> function) {
    Objects.requireNonNull(function);
    return (t, u, value) -> function.applyAsLong(u);
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjDoubleToLongFunction.java

/**
 * Creates a {@link BiObjDoubleToLongFunction} which uses the {@code first} parameter of this one as argument for
 * the given {@link ToLongFunction}./*from  w  ww.  ja  v a2s .c  o m*/
 *
 * @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 which accepts the {@code first} parameter of this one
 * @return Creates a {@code BiObjDoubleToLongFunction} which uses the {@code first} parameter of this one as
 * argument for the given {@code ToLongFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiObjDoubleToLongFunction<T, U> onlyFirst(@Nonnull final ToLongFunction<? super T> function) {
    Objects.requireNonNull(function);
    return (t, u, value) -> function.applyAsLong(t);
}

From source file:at.gridtec.lambda4j.function.tri.obj.BiObjDoubleToLongFunction.java

/**
 * Creates a {@link BiObjDoubleToLongFunction} which uses the {@code second} parameter of this one as argument for
 * the given {@link ToLongFunction}./*  w  w w . ja  v  a  2  s. c  om*/
 *
 * @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 which accepts the {@code second} parameter of this one
 * @return Creates a {@code BiObjDoubleToLongFunction} which uses the {@code second} parameter of this one as
 * argument for the given {@code ToLongFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiObjDoubleToLongFunction<T, U> onlySecond(@Nonnull final ToLongFunction<? super U> function) {
    Objects.requireNonNull(function);
    return (t, u, value) -> function.applyAsLong(u);
}

From source file:at.gridtec.lambda4j.function.bi.obj.ObjLongFunction.java

/**
 * Returns a composed {@link BiFunction2} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <A> The type of the argument to the first given function, and of composed function
 * @param <B> The type of the argument to the second given function, and of composed function
 * @param before1 The first function to apply before this function is applied
 * @param before2 The second function to apply before this function is applied
 * @return A composed {@code BiFunction2} that first applies the {@code before} functions to its input, and then
 * applies this function to the result./*  w w  w .  j a va  2  s .c o m*/
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to handle every type.
 */
@Nonnull
default <A, B> BiFunction2<A, B, R> compose(@Nonnull final Function<? super A, ? extends T> before1,
        @Nonnull final ToLongFunction<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> apply(before1.apply(a), before2.applyAsLong(b));
}

From source file:at.gridtec.lambda4j.function.bi.BiLongFunction.java

/**
 * Returns a composed {@link BiFunction2} that first applies the {@code before} functions to its input, and
 * then applies this function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <A> The type of the argument to the first given function, and of composed function
 * @param <B> The type of the argument to the second given function, and of composed function
 * @param before1 The first function to apply before this function is applied
 * @param before2 The second function to apply before this function is applied
 * @return A composed {@code BiFunction2} that first applies the {@code before} functions to its input, and then
 * applies this function to the result./*w  w  w  .j  ava 2s.com*/
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to handle every type.
 */
@Nonnull
default <A, B> BiFunction2<A, B, R> compose(@Nonnull final ToLongFunction<? super A> before1,
        @Nonnull final ToLongFunction<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> apply(before1.applyAsLong(a), before2.applyAsLong(b));
}