Example usage for java.util.function IntFunction apply

List of usage examples for java.util.function IntFunction apply

Introduction

In this page you can find the example usage for java.util.function IntFunction apply.

Prototype

R apply(int value);

Source Link

Document

Applies this function to the given argument.

Usage

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

/**
 * Creates a {@link ObjIntFunction} which uses the {@code second} parameter of this one as argument for the given
 * {@link IntFunction}./* w  ww  .ja  va2s  .  c  o  m*/
 *
 * @param <T> The type of the first argument to the function
 * @param <R> The type of return value from the function
 * @param function The function which accepts the {@code second} parameter of this one
 * @return Creates a {@code ObjIntFunction} which uses the {@code second} parameter of this one as argument for the
 * given {@code IntFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, R> ObjIntFunction<T, R> onlySecond(@Nonnull final IntFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (t, value) -> function.apply(value);
}

From source file:at.gridtec.lambda4j.function.tri.TriIntFunction.java

/**
 * Creates a {@link TriIntFunction} which uses the {@code first} parameter of this one as argument for the given
 * {@link IntFunction}./*from   w  w  w.  java  2s . c  o  m*/
 *
 * @param <R> The type of return value from the function
 * @param function The function which accepts the {@code first} parameter of this one
 * @return Creates a {@code TriIntFunction} which uses the {@code first} parameter of this one as argument for the
 * given {@code IntFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <R> TriIntFunction<R> onlyFirst(@Nonnull final IntFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (value1, value2, value3) -> function.apply(value1);
}

From source file:at.gridtec.lambda4j.function.tri.TriIntFunction.java

/**
 * Creates a {@link TriIntFunction} which uses the {@code second} parameter of this one as argument for the given
 * {@link IntFunction}.//ww  w. ja  va 2  s.  c o m
 *
 * @param <R> The type of return value from the function
 * @param function The function which accepts the {@code second} parameter of this one
 * @return Creates a {@code TriIntFunction} which uses the {@code second} parameter of this one as argument for the
 * given {@code IntFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <R> TriIntFunction<R> onlySecond(@Nonnull final IntFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (value1, value2, value3) -> function.apply(value2);
}

From source file:at.gridtec.lambda4j.function.tri.TriIntFunction.java

/**
 * Creates a {@link TriIntFunction} which uses the {@code third} parameter of this one as argument for the given
 * {@link IntFunction}./*from  www. ja  v a2s .co  m*/
 *
 * @param <R> The type of return value from the function
 * @param function The function which accepts the {@code third} parameter of this one
 * @return Creates a {@code TriIntFunction} which uses the {@code third} parameter of this one as argument for the
 * given {@code IntFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <R> TriIntFunction<R> onlyThird(@Nonnull final IntFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (value1, value2, value3) -> function.apply(value3);
}

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

/**
 * Creates a {@link ObjBiIntFunction} which uses the {@code second} parameter of this one as argument for the given
 * {@link IntFunction}./*from ww  w  .j a  v a 2 s.  c om*/
 *
 * @param <T> The type of the first argument to the function
 * @param <R> The type of return value from the function
 * @param function The function which accepts the {@code second} parameter of this one
 * @return Creates a {@code ObjBiIntFunction} which uses the {@code second} parameter of this one as argument for
 * the given {@code IntFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, R> ObjBiIntFunction<T, R> onlySecond(@Nonnull final IntFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (t, value1, value2) -> function.apply(value1);
}

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

/**
 * Creates a {@link ObjBiIntFunction} which uses the {@code third} parameter of this one as argument for the given
 * {@link IntFunction}.//  w w w.j  av a 2s.  c  o  m
 *
 * @param <T> The type of the first argument to the function
 * @param <R> The type of return value from the function
 * @param function The function which accepts the {@code third} parameter of this one
 * @return Creates a {@code ObjBiIntFunction} which uses the {@code third} parameter of this one as argument for the
 * given {@code IntFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, R> ObjBiIntFunction<T, R> onlyThird(@Nonnull final IntFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (t, value1, value2) -> function.apply(value2);
}

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

/**
 * Creates a {@link BiObjIntFunction} which uses the {@code third} parameter of this one as argument for the given
 * {@link IntFunction}./*from   w  w 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 <R> The type of return value from the function
 * @param function The function which accepts the {@code third} parameter of this one
 * @return Creates a {@code BiObjIntFunction} which uses the {@code third} parameter of this one as argument for the
 * given {@code IntFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U, R> BiObjIntFunction<T, U, R> onlyThird(@Nonnull final IntFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (t, u, value) -> function.apply(value);
}

From source file:io.logspace.system.SolrClientResource.java

public void assertSolrNumFound(String message, String baseUrl, IntFunction<Boolean> eval) {
    JsonNode rootNode;/*from   ww w .j  a v a2s .  co  m*/
    try {
        rootNode = this.httpClient.execute(new HttpGet(baseUrl + "/api/native-query?q=*:*&rows=0"),
                JSON_NODE_RESPONSE_HANLDER);
        int actualNumFound = rootNode.path("response").path("numFound").asInt();
        assertTrue(message + " Actual found " + actualNumFound + " event(s).", eval.apply(actualNumFound));
    } catch (IOException e) {
        fail("Error while accessing Solr " + baseUrl + ": " + e.getMessage());
    }
}

From source file:at.gridtec.lambda4j.function.bi.to.ToIntBiFunction2.java

/**
 * Returns a composed {@link BiFunction2} that first applies this function to its input, and then applies the
 * {@code after} function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <S> The type of return value from the {@code after} function, and of the composed function
 * @param after The function to apply after this function is applied
 * @return A composed {@code BiFunction2} that first applies this function to its input, and then applies the {@code
 * after} function to the result.//  ww  w. j  a  va2 s  . c o  m
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to return every type.
 */
@Nonnull
default <S> BiFunction2<T, U, S> andThen(@Nonnull final IntFunction<? extends S> after) {
    Objects.requireNonNull(after);
    return (t, u) -> after.apply(applyAsInt(t, u));
}

From source file:at.gridtec.lambda4j.function.tri.to.ToIntTriFunction.java

/**
 * Returns a composed {@link TriFunction} that first applies this function to its input, and then applies the
 * {@code after} function to the result.
 * If evaluation of either operation throws an exception, it is relayed to the caller of the composed operation.
 *
 * @param <S> The type of return value from the {@code after} function, and of the composed function
 * @param after The function to apply after this function is applied
 * @return A composed {@code TriFunction} that first applies this function to its input, and then applies the {@code
 * after} function to the result./* ww w  . ja  va  2 s .  co m*/
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to return every type.
 */
@Nonnull
default <S> TriFunction<T, U, V, S> andThen(@Nonnull final IntFunction<? extends S> after) {
    Objects.requireNonNull(after);
    return (t, u, v) -> after.apply(applyAsInt(t, u, v));
}