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:org.keycloak.testsuite.adapter.AbstractExampleAdapterTest.java

protected static WebArchive exampleDeployment(String name, Consumer<WebArchive> additionalResources) {
    WebArchive webArchive = ShrinkWrap.create(ZipImporter.class, name + ".war")
            .importFrom(new File(EXAMPLES_HOME + "/" + name + "-" + EXAMPLES_VERSION_SUFFIX + ".war"))
            .as(WebArchive.class).addAsWebInfResource(jbossDeploymentStructure, JBOSS_DEPLOYMENT_STRUCTURE_XML);

    additionalResources.accept(webArchive);

    modifyOIDCAdapterConfig(webArchive);

    return webArchive;
}

From source file:fr.landel.utils.assertor.helper.HelperMessage.java

/**
 * Generates parameter string with default format for each supported types
 * //from w  w  w  . j a  v  a  2  s .  co  m
 * @param index
 *            The index
 * @param type
 *            The index parameter type
 * @return the parameter string
 */
protected static StringBuilder getParam(final int index, final EnumType type) {
    Objects.requireNonNull(type, MISSING_PARAM_TYPE);
    final StringBuilder stringBuilder = new StringBuilder();

    final Consumer<String> append = s -> stringBuilder.append(PREFIX_PERCENT).append(index).append(s);

    switch (type) {
    case BOOLEAN:
        append.accept(SUFFIX_BOOLEAN);
        break;
    case NUMBER_INTEGER:
        append.accept(SUFFIX_INTEGER);
        break;
    case NUMBER_DECIMAL:
        append.accept(SUFFIX_DECIMAL);
        break;
    case DATE:
    case CALENDAR:
        append.accept(SUFFIX_TIME_YEAR);
        append.accept(SUFFIX_TIME_MONTH);
        append.accept(SUFFIX_TIME_DAY);
        append.accept(SUFFIX_TIME_HOUR);
        append.accept(SUFFIX_TIME_MINUTE);
        append.accept(SUFFIX_TIME_SECOND);
        append.accept(SUFFIX_TIME_ZONE);
        break;
    default: // CHAR_SEQUENCE, TEMPORAL, THROWABLE...
        append.accept(SUFFIX_CHAR_SEQUENCE);
    }

    return stringBuilder;
}

From source file:com.google.cloud.runtimes.builder.Application.java

private static void doForEachOverrideSetting(List<Field> configFields, Consumer<String> actionBooleanSetting,
        Consumer<String> actionStringSetting) {
    for (Field field : configFields) {
        String name = OverrideableSetting.getSettingName(field);
        if ((field.getType().equals(boolean.class) || field.getType().equals(Boolean.class))) {
            actionBooleanSetting.accept(name);
        } else {/* ww w.  j a  va2 s .  co m*/
            actionStringSetting.accept(name);
        }
    }
}

From source file:org.nuxeo.ecm.core.api.CoreInstance.java

/**
 * Runs the given {@link Consumer} with a system {@link CoreSession} while logged in as a system user.
 *
 * @param session an existing session//from ww  w.  j  a va 2 s .  c om
 * @param consumer the consumer taking a system {@link CoreSession}
 * @since 8.4
 */
public static void doPrivileged(CoreSession session, Consumer<CoreSession> consumer) {
    new UnrestrictedSessionRunner(session) {
        @Override
        public void run() {
            consumer.accept(session);
        }
    }.runUnrestricted();
}

From source file:com.kotcrab.vis.editor.util.FileUtils.java

public static void streamFilesRecursively(FileHandle folder, Consumer<FileHandle> consumer) {
    if (folder.isDirectory() == false)
        throw new IllegalStateException("Folder must be directory!");

    for (FileHandle file : folder.list()) {
        if (file.isDirectory()) {
            streamFilesRecursively(file, consumer);
        } else {/*from w  w  w  .j  ava 2  s  . c  o  m*/
            consumer.accept(file);
        }
    }
}

From source file:org.nuxeo.ecm.core.api.CoreInstance.java

/**
 * Runs the given {@link Consumer} with a system {@link CoreSession} while logged in as a system user.
 *
 * @param repositoryName the repository name for the {@link CoreSession}
 * @param consumer the consumer taking a system {@link CoreSession}
 * @since 8.4//from ww w  . j  av a2  s.  c o m
 */
public static void doPrivileged(String repositoryName, Consumer<CoreSession> consumer) {
    new UnrestrictedSessionRunner(repositoryName, getCurrentPrincipalName()) {
        @Override
        public void run() {
            consumer.accept(session);
        }
    }.runUnrestricted();
}

From source file:de.ks.text.view.AsciiDocViewer.java

public static CompletableFuture<DefaultLoader<Node, AsciiDocViewer>> load(Consumer<StackPane> viewConsumer,
        Consumer<AsciiDocViewer> controllerConsumer) {
    ActivityInitialization initialization = CDI.current().select(ActivityInitialization.class).get();
    return initialization.loadAdditionalControllerWithFuture(AsciiDocViewer.class)//
            .thenApply(loader -> {//from   www . j ava2s.  co m
                viewConsumer.accept((StackPane) loader.getView());
                controllerConsumer.accept(loader.getController());
                return loader;
            });
}

From source file:com.vmware.admiral.compute.ConfigureHostOverSshTaskService.java

public static void validate(ServiceHost host, ConfigureHostOverSshTaskServiceState state,
        Consumer<Throwable> consumer) {
    if (state.address == null || state.address.equals("")) {
        consumer.accept(new LocalizableValidationException(ADDRESS_NOT_SET_ERROR_MESSAGE,
                "compute.configure.host.address.missing"));
    }/*from ww w. j a  v a 2 s.  c  o m*/
    if (state.port == null || state.port < 0) {
        consumer.accept(new LocalizableValidationException(PORT_NOT_SET_ERROR_MESSAGE,
                "compute.configure.host.port.missing"));
    }

    // Verify connectivity and that the user is root or another sudoer
    fetchCredentials(host, state.authCredentialsLink, (op, failure) -> {
        if (failure != null) {
            consumer.accept(failure);
            return;
        }

        AuthCredentialsServiceState creds = op.getBody(AuthCredentialsServiceState.class);

        String command = "echo 1234";
        if (!isRoot(creds)) {
            command = "sudo " + command;
        }

        getSshServiceUtil(host).exec(state.address, creds, command, (sshOp, sshFailure) -> {
            if (sshFailure != null) {
                consumer.accept(sshFailure);
                return;
            }

            consumer.accept(null);
        }, SshServiceUtil.SSH_OPERATION_TIMEOUT_MEDIUM, TimeUnit.SECONDS);
    });
}

From source file:com.streamsets.datacollector.pipeline.executor.spark.yarn.YarnAppLauncher.java

private static void applyConfIfPresent(String config, Consumer<? super String> configFn) {
    // Empty is valid, since the user may have just created a new one by clicking (+), but not
    // entered anything. So just don't pass it along.
    if (!StringUtils.isEmpty(config)) {
        configFn.accept(config);
    }/*  w  ww.ja  va 2  s .c o m*/
}

From source file:org.apache.openmeetings.core.converter.DocumentConverter.java

public static void createOfficeManager(String officePath, Consumer<OfficeManager> consumer) {
    OfficeManager manager = null;/*from   w  w w  .  j  a  v a  2 s .  c  o m*/
    try {
        DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
        if (!Strings.isEmpty(officePath)) {
            configuration.setOfficeHome(officePath);
        }
        manager = configuration.buildOfficeManager();
        manager.start();
        if (consumer != null) {
            consumer.accept(manager);
        }
    } finally {
        if (manager != null) {
            manager.stop();
        }
    }
}