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.consumer.tri.obj.BiObjDoubleConsumer.java

/**
 * Creates a {@link BiObjDoubleConsumer} which uses the {@code second} parameter of this one as argument for the
 * given {@link Consumer}.//from www . j  a v  a  2 s  .  c o  m
 *
 * @param <T> The type of the first argument to the consumer
 * @param <U> The type of the second argument to the consumer
 * @param consumer The consumer which accepts the {@code second} parameter of this one
 * @return Creates a {@code BiObjDoubleConsumer} which uses the {@code second} parameter of this one as argument for
 * the given {@code Consumer}.
 * @throws NullPointerException If given argument is {@code null}
 */
@Nonnull
static <T, U> BiObjDoubleConsumer<T, U> onlySecond(@Nonnull final Consumer<? super U> consumer) {
    Objects.requireNonNull(consumer);
    return (t, u, value) -> consumer.accept(u);
}

From source file:org.commonjava.indy.bind.jaxrs.util.ResponseUtils.java

public static Response formatCreatedResponse(final String baseUri, final CreationDTO dto,
        final Consumer<ResponseBuilder> builderModifer) {
    ResponseBuilder builder = Response.created(dto.getUri()).entity(dto.getJsonResponse());
    if (builderModifer != null) {
        builderModifer.accept(builder);
    }/*from   w w  w .j ava2s .  co  m*/

    return builder.build();
}

From source file:net.objectlab.kit.util.StringUtil.java

/**
 * If the string is not blank call the consumer (depends on JDK8+)
 * @param text/*from  ww w .j av  a  2  s .  c  o  m*/
 * @param consumer
 * @return true if consumed
 * @since 1.4.0
 */
public static boolean ifNotBlank(final String text, final Consumer<String> consumer) {
    if (StringUtils.isNotBlank(text)) {
        consumer.accept(text);
        return true;
    }
    return false;
}

From source file:cz.lbenda.gui.controls.TextAreaFrmController.java

public static EventHandler<ActionEvent> openEventHandler(String windowTitle,
        @Nonnull Supplier<String> oldValueSupplier, @Nonnull Consumer<String> newValueConsumer) {
    String title = windowTitle == null ? msgDefaultWindowTitle : windowTitle;
    return event -> {
        Tuple2<Parent, TextAreaFrmController> tuple2 = TextAreaFrmController.createNewInstance();
        tuple2.get2().textProperty().setValue(oldValueSupplier.get());
        tuple2.get2().textProperty()/* ww w  . j  av a  2s  . co m*/
                .addListener((observable, oldValue, newValue) -> newValueConsumer.accept(newValue));
        Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
        DialogHelper.getInstance().openWindowInCenterOfStage(stage, tuple2.get2().getMainPane(), title);
    };
}

From source file:org.commonjava.indy.bind.jaxrs.util.ResponseUtils.java

public static Response formatRedirect(final URI uri, final Consumer<ResponseBuilder> builderModifier)
        throws URISyntaxException {
    ResponseBuilder builder = Response.status(Status.MOVED_PERMANENTLY).location(uri);
    if (builderModifier != null) {
        builderModifier.accept(builder);
    }//from   w w w  .  j ava 2  s .c om

    return builder.build();
}

From source file:com.edduarte.protbox.Protbox.java

private static void insertPassword(Consumer<SecretKey> passwordKeyConsumer) {
    InsertPasswordWindow.showPrompt(pw -> {
        // decode the serialized directories using the password
        // if password results in error, this registry does not belong to this user
        pw = pw + pw + pw + pw;/*from w w w.  ja  va  2  s .  c  o  m*/

        SecretKey sKey = new SecretKeySpec(pw.getBytes(), "AES");
        passwordKeyConsumer.accept(sKey);
    });
}

From source file:org.commonjava.indy.bind.jaxrs.util.ResponseUtils.java

public static Response formatBadRequestResponse(final String error,
        final Consumer<ResponseBuilder> builderModifier) {
    final String msg = "{\"error\": \"" + error + "\"}\n";
    ResponseBuilder builder = Response.status(Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON).entity(msg);
    if (builderModifier != null) {
        builderModifier.accept(builder);
    }//from   w w w .java 2  s  .  co  m

    return builder.build();
}

From source file:org.commonjava.indy.bind.jaxrs.util.ResponseUtils.java

public static Response formatCreatedResponse(final String baseUri, final UriFormatter uriFormatter,
        final Consumer<ResponseBuilder> builderModifier, final String... params) throws URISyntaxException {
    final URI location = new URI(uriFormatter.formatAbsolutePathTo(baseUri, params));
    ResponseBuilder builder = Response.created(location);
    if (builderModifier != null) {
        builderModifier.accept(builder);
    }//from   w ww .  j  ava2  s.  co m

    return builder.build();
}

From source file:com.evolveum.midpoint.schema.SelectorOptions.java

public static <T> Collection<SelectorOptions<T>> updateRootOptions(Collection<SelectorOptions<T>> options,
        Consumer<T> updater, Supplier<T> newValueSupplier) {
    if (options == null) {
        options = new ArrayList<>();
    }/*from  w  ww . j  a  v  a  2  s .  com*/
    T rootOptions = findRootOptions(options);
    if (rootOptions == null) {
        rootOptions = newValueSupplier.get();
        options.add(new SelectorOptions<>(rootOptions));
    }
    updater.accept(rootOptions);
    return options;
}

From source file:com.qwazr.server.configuration.ServerConfiguration.java

protected static void fillStringListProperty(final String value, final String separatorChars,
        final boolean trim, final Consumer<String> consumer) {
    if (value == null)
        return;/*  w ww  .  j a  va2 s.  c o  m*/
    final String[] parts = StringUtils.split(value, separatorChars);
    for (String part : parts)
        if (part != null)
            consumer.accept(trim ? part.trim() : part);
}