Example usage for java.util.function LongFunction apply

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

Introduction

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

Prototype

R apply(long value);

Source Link

Document

Applies this function to the given argument.

Usage

From source file:gedi.util.FileUtils.java

public static long download(File file, String url, UnaryOperator<InputStream> streamAdapter, Progress progress,
        LongFunction<String> bytesToMessage) throws MalformedURLException, IOException {
    final byte[] buffer = new byte[8024];
    int n = 0;/*from   w w w .  ja  v a 2s  .c om*/
    long count = 0;
    InputStream input = new URL(url).openStream();
    if (streamAdapter != null)
        input = streamAdapter.apply(input);
    OutputStream output = new FileOutputStream(file);
    while (-1 != (n = input.read(buffer))) {
        output.write(buffer, 0, n);
        count += n;
        long ucount = count;
        progress.incrementProgress().setDescription(() -> bytesToMessage.apply(ucount));
    }
    input.close();
    output.close();
    return count;
}

From source file:at.gridtec.lambda4j.function.bi.to.ToLongBiFunction2.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./* w  w  w . j a  va 2 s .c om*/
 * @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 LongFunction<? extends S> after) {
    Objects.requireNonNull(after);
    return (t, u) -> after.apply(applyAsLong(t, u));
}

From source file:at.gridtec.lambda4j.function.tri.to.ToLongTriFunction.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./*from  ww w .j  a v  a  2s.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> TriFunction<T, U, V, S> andThen(@Nonnull final LongFunction<? extends S> after) {
    Objects.requireNonNull(after);
    return (t, u, v) -> after.apply(applyAsLong(t, u, v));
}

From source file:at.gridtec.lambda4j.function.bi.conversion.BiBooleanToLongFunction.java

/**
 * Returns a composed {@link BiBooleanFunction} 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 BiBooleanFunction} that first applies this function to its input, and then applies the
 * {@code after} function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to return every type.
 *//*from   w  ww .  j a v a  2 s. c o m*/
@Nonnull
default <S> BiBooleanFunction<S> andThen(@Nonnull final LongFunction<? extends S> after) {
    Objects.requireNonNull(after);
    return (value1, value2) -> after.apply(applyAsLong(value1, value2));
}

From source file:at.gridtec.lambda4j.function.bi.conversion.BiByteToLongFunction.java

/**
 * Returns a composed {@link BiByteFunction} 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 BiByteFunction} that first applies this function to its input, and then applies the
 * {@code after} function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to return every type.
 *///from www.  j av a2s. c o m
@Nonnull
default <S> BiByteFunction<S> andThen(@Nonnull final LongFunction<? extends S> after) {
    Objects.requireNonNull(after);
    return (value1, value2) -> after.apply(applyAsLong(value1, value2));
}

From source file:at.gridtec.lambda4j.function.bi.conversion.BiCharToLongFunction.java

/**
 * Returns a composed {@link BiCharFunction} 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 BiCharFunction} that first applies this function to its input, and then applies the
 * {@code after} function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to return every type.
 *///  w  ww .  j  a v a 2s  . c  o  m
@Nonnull
default <S> BiCharFunction<S> andThen(@Nonnull final LongFunction<? extends S> after) {
    Objects.requireNonNull(after);
    return (value1, value2) -> after.apply(applyAsLong(value1, value2));
}

From source file:at.gridtec.lambda4j.function.bi.conversion.BiFloatToLongFunction.java

/**
 * Returns a composed {@link BiFloatFunction} 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 BiFloatFunction} that first applies this function to its input, and then applies the
 * {@code after} function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to return every type.
 *//*from w  ww.jav  a 2 s .c o m*/
@Nonnull
default <S> BiFloatFunction<S> andThen(@Nonnull final LongFunction<? extends S> after) {
    Objects.requireNonNull(after);
    return (value1, value2) -> after.apply(applyAsLong(value1, value2));
}

From source file:at.gridtec.lambda4j.function.bi.conversion.BiShortToLongFunction.java

/**
 * Returns a composed {@link BiShortFunction} 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 BiShortFunction} that first applies this function to its input, and then applies the
 * {@code after} function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to return every type.
 *///from w ww .j  a  va 2  s . c  om
@Nonnull
default <S> BiShortFunction<S> andThen(@Nonnull final LongFunction<? extends S> after) {
    Objects.requireNonNull(after);
    return (value1, value2) -> after.apply(applyAsLong(value1, value2));
}

From source file:at.gridtec.lambda4j.function.bi.conversion.BiIntToLongFunction.java

/**
 * Returns a composed {@link BiIntFunction} 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 BiIntFunction} that first applies this function to its input, and then applies the
 * {@code after} function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to return every type.
 *///from w w w  .  j a va2 s .  com
@Nonnull
default <S> BiIntFunction<S> andThen(@Nonnull final LongFunction<? extends S> after) {
    Objects.requireNonNull(after);
    return (value1, value2) -> after.apply(applyAsLong(value1, value2));
}

From source file:at.gridtec.lambda4j.function.bi.conversion.BiDoubleToLongFunction.java

/**
 * Returns a composed {@link BiDoubleFunction} 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 BiDoubleFunction} that first applies this function to its input, and then applies the
 * {@code after} function to the result.
 * @throws NullPointerException If given argument is {@code null}
 * @implSpec The input argument of this method is able to return every type.
 */// w  ww .  ja va  2 s  .  c  o  m
@Nonnull
default <S> BiDoubleFunction<S> andThen(@Nonnull final LongFunction<? extends S> after) {
    Objects.requireNonNull(after);
    return (value1, value2) -> after.apply(applyAsLong(value1, value2));
}