Example usage for java.util.function ToIntFunction applyAsInt

List of usage examples for java.util.function ToIntFunction applyAsInt

Introduction

In this page you can find the example usage for java.util.function ToIntFunction applyAsInt.

Prototype

int applyAsInt(T value);

Source Link

Document

Applies this function to the given argument.

Usage

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

/**
 * Creates a {@link BiObjCharToIntFunction} which uses the {@code second} parameter of this one as argument for the
 * given {@link ToIntFunction}.// w  w w.jav  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 second} parameter of this one
 * @return Creates a {@code BiObjCharToIntFunction} which uses the {@code second} parameter of this one as argument
 * for the given {@code ToIntFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiObjCharToIntFunction<T, U> onlySecond(@Nonnull final ToIntFunction<? super U> function) {
    Objects.requireNonNull(function);
    return (t, u, value) -> function.applyAsInt(u);
}

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

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

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

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

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

/**
 * Creates a {@link BiObjShortToIntFunction} which uses the {@code first} parameter of this one as argument for the
 * given {@link ToIntFunction}.//from   www.  ja  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 first} parameter of this one
 * @return Creates a {@code BiObjShortToIntFunction} which uses the {@code first} parameter of this one as argument
 * for the given {@code ToIntFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiObjShortToIntFunction<T, U> onlyFirst(@Nonnull final ToIntFunction<? super T> function) {
    Objects.requireNonNull(function);
    return (t, u, value) -> function.applyAsInt(t);
}

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

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

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

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

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

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

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

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

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

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

From source file:at.gridtec.lambda4j.function.bi.obj.ObjIntFunction.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.//ww w. ja v a 2s  . c  om
 * @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 ToIntFunction<? super B> before2) {
    Objects.requireNonNull(before1);
    Objects.requireNonNull(before2);
    return (a, b) -> apply(before1.apply(a), before2.applyAsInt(b));
}