List of usage examples for java.util.function Consumer accept
void accept(T t);
From source file:org.codelibs.fess.helper.ProcessHelper.java
public synchronized JobProcess startProcess(final String sessionId, final List<String> cmdList, final Consumer<ProcessBuilder> pbCall) { final ProcessBuilder pb = new ProcessBuilder(cmdList); pbCall.accept(pb); destroyProcess(sessionId);/*from w w w . j a v a 2 s .c o m*/ JobProcess jobProcess; try { jobProcess = new JobProcess(pb.start()); destroyProcess(sessionId, runningProcessMap.putIfAbsent(sessionId, jobProcess)); return jobProcess; } catch (final IOException e) { throw new JobProcessingException("Crawler Process terminated.", e); } }
From source file:org.usrz.libs.httpd.ServerBuilder.java
public void install(Consumer<Binder> consumer) { consumer.accept(binder()); }
From source file:com.codelanx.codelanxlib.command.CommandNode.java
/** * Returns an anonymous {@link CommandNode} instance which is defined as * non-executable {@link CommandNode} used for chaining together other * {@link CommandNode} objects.// www . ja v a 2 s . c o m * * @since 0.1.0 * @version 0.1.0 * * @param <T> The type of the {@link Plugin} relevant to the new node * @param command The value for {@link CommandNode#getName()} * @param plugin The relevant {@link Plugin} to this new node * @param onConstruct Code to execute upon construction of the object, can * be {@code null} * @return The newly created {@link CommandNode} object */ public static <T extends Plugin> CommandNode<T> getLinkingNode(String command, T plugin, Consumer<CommandNode<T>> onConstruct) { Validate.notNull(command, "Command cannot be null"); Validate.notNull(plugin, "Plugin cannot be null"); return new CommandNode<T>(plugin) { private final Lang lang; { this.setExecutable(false); this.lang = Lang.createLang("This is a linking node for '" + command + "'"); if (onConstruct != null) { onConstruct.accept(this); } } @Override public CommandStatus execute(CommandSender sender, String... args) { return CommandStatus.NOT_EXECUTABLE; } @Override public List<String> tabComplete(CommandSender sender, String... args) { return TabInfo.BLANK_TAB_COMPLETE; } @Override public String getName() { return command; } @Override public Lang info() { return this.lang; } }; }
From source file:io.servicecomb.config.DynamicPropertiesImpl.java
@Override public String getStringProperty(String propertyName, Consumer<String> consumer, String defaultValue) { DynamicStringProperty prop = propertyFactoryInstance().getStringProperty(propertyName, defaultValue); prop.addCallback(() -> consumer.accept(prop.get())); return prop.get(); }
From source file:io.servicecomb.config.DynamicPropertiesImpl.java
@Override public boolean getBooleanProperty(String propertyName, Consumer<Boolean> consumer, boolean defaultValue) { DynamicBooleanProperty prop = propertyFactoryInstance().getBooleanProperty(propertyName, defaultValue); prop.addCallback(() -> consumer.accept(prop.get())); return prop.get(); }
From source file:io.bosh.client.internal.AbstractSpringOperations.java
protected final <T> Observable<T> get(Class<T> responseType, Consumer<UriComponentsBuilder> builderCallback) { return createObservable(() -> { UriComponentsBuilder builder = UriComponentsBuilder.fromUri(this.root); builderCallback.accept(builder); URI uri = builder.build().toUri(); this.logger.debug("GET {}", uri); return this.restOperations.getForObject(uri, responseType); });/* w ww. j ava 2s. co m*/ }
From source file:io.bosh.client.internal.AbstractSpringOperations.java
protected final <T> Observable<ResponseEntity<T>> getEntity(Class<T> responseType, Consumer<UriComponentsBuilder> builderCallback) { return createObservable(() -> { UriComponentsBuilder builder = UriComponentsBuilder.fromUri(this.root); builderCallback.accept(builder); URI uri = builder.build().toUri(); this.logger.debug("GET {}", uri); return this.restOperations.getForEntity(uri, responseType); });/*w w w.j a v a2 s. c o m*/ }
From source file:io.bosh.client.internal.AbstractSpringOperations.java
protected final <T> Observable<T> post(Class<T> responseType, Object request, Consumer<UriComponentsBuilder> builderCallback) { return createObservable(() -> { UriComponentsBuilder builder = UriComponentsBuilder.fromUri(this.root); builderCallback.accept(builder); URI uri = builder.build().toUri(); this.logger.debug("GET {}", uri); return this.restOperations.postForObject(uri, request, responseType); });//w w w . j a v a 2 s .c o m }
From source file:io.bosh.client.internal.AbstractSpringOperations.java
protected final <T> Observable<ResponseEntity<T>> postForEntity(Class<T> responseType, Object request, Consumer<UriComponentsBuilder> builderCallback) { return createObservable(() -> { UriComponentsBuilder builder = UriComponentsBuilder.fromUri(this.root); builderCallback.accept(builder); URI uri = builder.build().toUri(); this.logger.debug("POST {}", uri); return this.restOperations.postForEntity(uri, request, responseType); });//from w w w . java2s . co m }
From source file:io.bosh.client.internal.AbstractSpringOperations.java
protected final <T, R> Observable<ResponseEntity<R>> exchangeForEntity(T request, Class<R> responseType, HttpHeaders headers, HttpMethod method, Consumer<UriComponentsBuilder> builderCallback) { return createObservable(() -> { UriComponentsBuilder builder = UriComponentsBuilder.fromUri(this.root); builderCallback.accept(builder); URI uri = builder.build().toUri(); RequestEntity<T> requestEntity = new RequestEntity<T>(request, headers, HttpMethod.PUT, uri); this.logger.debug("{} {}", method, uri); return this.restOperations.exchange(requestEntity, responseType); });//from w w w . ja va 2 s. c om }