List of usage examples for java.util.function Consumer accept
void accept(T t);
From source file:org.mimacom.sample.integration.patterns.user.service.integration.HystrixSearchServiceIntegration.java
public void indexUserSlow(User user, int waitTime, Consumer<Void> successConsumer, Consumer<Throwable> failureConsumer) { IndexUserHystrixCommand hystrixCommand = new IndexUserHystrixCommand(user, this.restTemplate, this.searchServiceUrl + "/index?waitTime=" + waitTime); hystrixCommand.observe().subscribe((ignored) -> { successConsumer.accept(null); }, failureConsumer::accept);/*from w w w. j av a 2s.c o m*/ }
From source file:org.brickhouse.impl.MemoryTable2.java
@Override public void readAll(Filter filter, Consumer<HMap> consumer, boolean fillDii) { try {/*from w ww . j a v a2 s .c o m*/ for (HMap row : data.values()) { if (filter.include(row, pather)) { if (fillDii) fillDii(row); consumer.accept(new HMap(row)); } } } catch (CancelReadException e) { // no op } }
From source file:org.dhatim.fastexcel.Correctness.java
private byte[] writeWorkbook(Consumer<Workbook> consumer) throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); Workbook wb = new Workbook(os, "Test", "1.0"); consumer.accept(wb); wb.finish();//from w w w. jav a 2 s .c o m return os.toByteArray(); }
From source file:jease.cmf.domain.Node.java
/** * Applies given procedure to node and recursively to all children. *//* ww w . j a v a2 s.c om*/ public void traverse(final Consumer<Node> action) { action.accept(this); for (Node child : getChildren()) { child.traverse(action); } }
From source file:at.ac.tuwien.qse.sepm.service.impl.PhotoServiceImpl.java
@Override public void subscribeDelete(Consumer<Path> callback) { photoRepository.addListener(new PhotoRepository.Listener() { @Override/*w w w .j a v a 2 s . c om*/ public void onDelete(PhotoRepository repository, Path file) { LOGGER.info("deleted {}", file); callback.accept(file); } }); }
From source file:it.organization.OrganizationTest.java
private void verifyAnonymousNotAuthorized(Consumer<OrganizationService> consumer) { try {//from www .ja v a2 s. c o m consumer.accept(anonymousOrganizationService); fail("An HttpException should have been raised"); } catch (HttpException e) { assertThat(e.code()).isEqualTo(403); } }
From source file:it.organization.OrganizationTest.java
private void verifyUserNotAuthenticated(Consumer<OrganizationService> consumer) { try {/*from w w w. ja v a2 s . co m*/ consumer.accept(anonymousOrganizationService); fail("An HttpException should have been raised"); } catch (HttpException e) { assertThat(e.code()).isEqualTo(401); } }
From source file:at.gridtec.lambda4j.function.tri.TriFunction.java
/** * Returns a composed {@link TriConsumer} that fist applies this function to its input, and then consumes the result * using the given {@link Consumer}./*from ww w. ja v a 2s.c o m*/ * 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 TriConsumer} 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} */ @Nonnull default TriConsumer<T, U, V> consume(@Nonnull final Consumer<? super R> consumer) { Objects.requireNonNull(consumer); return (t, u, v) -> consumer.accept(apply(t, u, v)); }
From source file:com.netflix.spinnaker.halyard.config.model.v1.node.Node.java
public void recursiveConsume(Consumer<Node> consumer) { consumer.accept(this); NodeIterator children = getChildren(); Node child = children.getNext(); while (child != null) { child.recursiveConsume(consumer); child = children.getNext();/*from w w w . j a v a 2s . co m*/ } }
From source file:onl.area51.httpd.HttpServerBuilder.java
/** * Notify a consumer of this builder.// ww w .j av a 2s . co m * <p> * An example is notifying CDI beans observing the builder class. Use it with * {@code builder.notify( CDI.current().getBeanManager()::fireEvent )} and it will notify each bean with the builder, * allowing them to add to the server configuration. * * @param action * * @return */ default HttpServerBuilder notify(Consumer<ActionRegistry> action) { HttpServerBuilder b = this; action.accept(new ActionRegistry() { @Override public HttpRequestHandlerBuilder getGlobalHandlerBuilder() { return b.getGlobalHandlerBuilder(); } @Override public ActionRegistry registerHandler(String pattern, HttpRequestHandler handler) { b.registerHandler(pattern, handler); return this; } @Override public ActionRegistry addResponseInterceptorFirst(HttpResponseInterceptor itcp) { b.addInterceptorFirst(itcp); return this; } @Override public ActionRegistry addResponseInterceptorLast(HttpResponseInterceptor itcp) { b.addInterceptorLast(itcp); return this; } @Override public ActionRegistry addRequestInterceptorFirst(HttpRequestInterceptor itcp) { b.addInterceptorFirst(itcp); return this; } @Override public ActionRegistry addRequestInterceptorLast(HttpRequestInterceptor itcp) { b.addInterceptorLast(itcp); return this; } @Override public ActionRegistry addContextListener(ContextListener cl) { return addRequestInterceptorFirst((r, c) -> { if (c.getAttribute("request.unscoped") == null) { cl.begin(r, c); } }).addResponseInterceptorLast((r, c) -> { if (c.getAttribute("request.unscoped") == null) { cl.end(r, c); } }); } }); return this; }