Example usage for java.util.function DoubleFunction apply

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

Introduction

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

Prototype

R apply(double value);

Source Link

Document

Applies this function to the given argument.

Usage

From source file:Main.java

public static void main(String[] args) {
    DoubleFunction<String> df = (d) -> d + " is now a string";

    System.out.println(df.apply(0.5));

}

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

/**
 * Creates a {@link BiDoubleFunction} which uses the {@code first} parameter of this one as argument for the given
 * {@link DoubleFunction}./*  ww w.  j  a  v  a  2 s . 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 BiDoubleFunction} which uses the {@code first} parameter of this one as argument for the
 * given {@code DoubleFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <R> BiDoubleFunction<R> onlyFirst(@Nonnull final DoubleFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (value1, value2) -> function.apply(value1);
}

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

/**
 * Creates a {@link BiDoubleFunction} which uses the {@code second} parameter of this one as argument for the given
 * {@link DoubleFunction}./*from  w w  w  .  jav  a  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 BiDoubleFunction} which uses the {@code second} parameter of this one as argument for
 * the given {@code DoubleFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <R> BiDoubleFunction<R> onlySecond(@Nonnull final DoubleFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (value1, value2) -> function.apply(value2);
}

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

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

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

/**
 * Creates a {@link TriDoubleFunction} which uses the {@code first} parameter of this one as argument for the given
 * {@link DoubleFunction}./*from   w  w  w  .jav  a2  s  .  com*/
 *
 * @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 TriDoubleFunction} which uses the {@code first} parameter of this one as argument for
 * the given {@code DoubleFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <R> TriDoubleFunction<R> onlyFirst(@Nonnull final DoubleFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (value1, value2, value3) -> function.apply(value1);
}

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

/**
 * Creates a {@link TriDoubleFunction} which uses the {@code second} parameter of this one as argument for the given
 * {@link DoubleFunction}./*from w  w w. j  a  va  2s  .  com*/
 *
 * @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 TriDoubleFunction} which uses the {@code second} parameter of this one as argument for
 * the given {@code DoubleFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <R> TriDoubleFunction<R> onlySecond(@Nonnull final DoubleFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (value1, value2, value3) -> function.apply(value2);
}

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

/**
 * Creates a {@link TriDoubleFunction} which uses the {@code third} parameter of this one as argument for the given
 * {@link DoubleFunction}./*from   w  w w .ja v  a  2 s  .  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 TriDoubleFunction} which uses the {@code third} parameter of this one as argument for
 * the given {@code DoubleFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <R> TriDoubleFunction<R> onlyThird(@Nonnull final DoubleFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (value1, value2, value3) -> function.apply(value3);
}

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

/**
 * Creates a {@link ObjBiDoubleFunction} which uses the {@code second} parameter of this one as argument for the
 * given {@link DoubleFunction}./*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 <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 ObjBiDoubleFunction} which uses the {@code second} parameter of this one as argument for
 * the given {@code DoubleFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, R> ObjBiDoubleFunction<T, R> onlySecond(@Nonnull final DoubleFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (t, value1, value2) -> function.apply(value1);
}

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

/**
 * Creates a {@link ObjBiDoubleFunction} which uses the {@code third} parameter of this one as argument for the
 * given {@link DoubleFunction}.//from w  w  w .j  a va 2s  .  co  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 ObjBiDoubleFunction} which uses the {@code third} parameter of this one as argument for
 * the given {@code DoubleFunction}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, R> ObjBiDoubleFunction<T, R> onlyThird(@Nonnull final DoubleFunction<? extends R> function) {
    Objects.requireNonNull(function);
    return (t, value1, value2) -> function.apply(value2);
}

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

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