Example usage for java.util.function Consumer accept

List of usage examples for java.util.function Consumer accept

Introduction

In this page you can find the example usage for java.util.function Consumer accept.

Prototype

void accept(T t);

Source Link

Document

Performs this operation on the given argument.

Usage

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

/**
 * Returns a composed {@link ObjByteConsumer} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code ObjByteConsumer} that first applies this function to its input, and then consumes the
 * result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *//*from w  w  w . ja  v a  2 s.  c o  m*/
@Nonnull
default ObjByteConsumer<T> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, value) -> consumer.accept(apply(t, value));
}

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

/**
 * Returns a composed {@link ObjCharConsumer} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code ObjCharConsumer} that first applies this function to its input, and then consumes the
 * result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *//*  w  w  w  .  j a  v  a 2  s . com*/
@Nonnull
default ObjCharConsumer<T> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, value) -> consumer.accept(apply(t, value));
}

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

/**
 * Returns a composed {@link ObjBooleanConsumer} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code ObjBooleanConsumer} that first applies this function to its input, and then consumes
 * the result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *//*from  w ww .jav  a2  s . c  o m*/
@Nonnull
default ObjBooleanConsumer<T> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, value) -> consumer.accept(apply(t, value));
}

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

/**
 * Returns a composed {@link ObjFloatConsumer} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code ObjFloatConsumer} that first applies this function to its input, and then consumes the
 * result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *///from  w  ww.j  av  a2 s. c  om
@Nonnull
default ObjFloatConsumer<T> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, value) -> consumer.accept(apply(t, value));
}

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

/**
 * Returns a composed {@link ObjIntConsumer2} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code ObjIntConsumer2} that first applies this function to its input, and then consumes the
 * result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *//*from w  ww  .jav a2 s.  co m*/
@Nonnull
default ObjIntConsumer2<T> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, value) -> consumer.accept(apply(t, value));
}

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

/**
 * Returns a composed {@link ObjLongConsumer2} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code ObjLongConsumer2} that first applies this function to its input, and then consumes the
 * result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *//*www  . java2 s  .co  m*/
@Nonnull
default ObjLongConsumer2<T> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, value) -> consumer.accept(apply(t, value));
}

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

/**
 * Returns a composed {@link ObjShortConsumer} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code ObjShortConsumer} that first applies this function to its input, and then consumes the
 * result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *///from   w  ww  .j  a v  a  2  s .c  om
@Nonnull
default ObjShortConsumer<T> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, value) -> consumer.accept(apply(t, value));
}

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

/**
 * Returns a composed {@link ObjDoubleConsumer2} that fist applies this function to its input, and then consumes the
 * result using the given {@link Consumer}. If evaluation of either operation throws an exception, it is relayed to
 * the caller of the composed operation.
 *
 * @param consumer The operation which consumes the result from this operation
 * @return A composed {@code ObjDoubleConsumer2} that first applies this function to its input, and then consumes
 * the result using the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 *//*from   w w  w .j a  va2s  .  c  o m*/
@Nonnull
default ObjDoubleConsumer2<T> consume(@Nonnull final Consumer<? super R> consumer) {
    Objects.requireNonNull(consumer);
    return (t, value) -> consumer.accept(apply(t, value));
}

From source file:com.example.bot.spring.KitchenSinkController.java

private void handleHeavyContent(String replyToken, String messageId, Consumer<ResponseBody> messageConsumer)
        throws IOException {
    Response<ResponseBody> response = lineMessagingService.getMessageContent(messageId).execute();
    if (response.isSuccessful()) {
        try (ResponseBody body = response.body()) {
            messageConsumer.accept(body);
        }//w ww.  ja  v  a 2 s.c om
    } else {
        reply(replyToken, new TextMessage("Cannot get image: " + response.message()));
    }

}

From source file:it.organization.OrganizationTest.java

private void verifyUserNotAuthorized(String login, String password, Consumer<OrganizationService> consumer) {
    try {//from w  ww.j  a v a2  s.  c o  m
        OrganizationService organizationService = newUserWsClient(orchestrator, login, password)
                .organizations();
        consumer.accept(organizationService);
        fail("An HttpException should have been raised");
    } catch (HttpException e) {
        assertThat(e.code()).isEqualTo(403);
    }
}