List of usage examples for java.util.function Consumer accept
void accept(T t);
From source file:io.tilt.minka.business.impl.TransportlessLeaderShardContainer.java
public final void observeForChange(Consumer<NetworkShardID> consumer) { logger.info("{}: ({}) Adding to observation group: {} (hash {})", getClass().getSimpleName(), myShardId, consumer, consumer.hashCode()); this.observers.add(consumer); // already elected then tell him if (leaderShardId != null) { logger.info("{}: ({}) Leader election already happened !: calling {} for consumption (hash {})", getClass().getSimpleName(), myShardId, consumer, consumer.hashCode()); consumer.accept(leaderShardId); }// ww w .ja v a 2 s. co m }
From source file:de.pixida.logtest.designer.automaton.AutomatonNode.java
protected void createTextAreaInput(final int numLines, final ConfigFrame cf, final String propertyName, final String initialValue, final Consumer<String> applyValue) { final TextArea inputField = new TextArea(initialValue); inputField.setPrefRowCount(numLines); inputField.setWrapText(true);/*from w ww .j av a 2s .c o m*/ inputField.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> { applyValue.accept(newValue); this.getGraph().handleChange(); }); cf.addOption(propertyName, inputField); }
From source file:at.gridtec.lambda4j.function.tri.TriBooleanFunction.java
/** * Returns a composed {@link TriBooleanConsumer} 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 TriBooleanConsumer} 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} *//* ww w . j av a 2s . c o m*/ @Nonnull default TriBooleanConsumer consume(@Nonnull final Consumer<? super R> consumer) { Objects.requireNonNull(consumer); return (value1, value2, value3) -> consumer.accept(apply(value1, value2, value3)); }
From source file:io.syndesis.jsondb.impl.SqlJsonDB.java
@Override public Consumer<OutputStream> getAsStreamingOutput(String path, GetOptions options) { GetOptions o;//from w w w.j a v a 2 s .c o m if (options != null) { o = options; } else { o = new GetOptions(); } // Lets normalize the path a bit String baseDBPath = JsonRecordSupport.convertToDBPath(path); String like = baseDBPath + "%"; Consumer<OutputStream> result = null; final Handle h = dbi.open(); try { // Creating the iterator could fail with a runtime exception, String sql = "select path,value,kind from jsondb where path LIKE :like order by path"; ResultIterator<JsonRecord> iterator = h.createQuery(sql).bind("like", like) .map(JsonRecordMapper.INSTANCE).iterator(); try { // At this point we know if we can produce results.. if (iterator.hasNext()) { result = output -> { try { Consumer<JsonRecord> toJson = JsonRecordSupport.recordsToJsonStream(baseDBPath, output, o); iterator.forEachRemaining(toJson); toJson.accept(null); } catch (IOException e) { throw new JsonDBException(e); } finally { iterator.close(); h.close(); } }; } } finally { // if we are producing results, then defer closing the iterator if (result == null) { iterator.close(); } } } finally { // if we are producing results, then defer closing the handle if (result == null) { h.close(); } } return result; }
From source file:at.gridtec.lambda4j.function.tri.TriByteFunction.java
/** * Returns a composed {@link TriByteConsumer} 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 TriByteConsumer} 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 ww . java2 s . c om @Nonnull default TriByteConsumer consume(@Nonnull final Consumer<? super R> consumer) { Objects.requireNonNull(consumer); return (value1, value2, value3) -> consumer.accept(apply(value1, value2, value3)); }
From source file:at.gridtec.lambda4j.function.tri.TriCharFunction.java
/** * Returns a composed {@link TriCharConsumer} 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 TriCharConsumer} 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. jav a2s .c o m*/ @Nonnull default TriCharConsumer consume(@Nonnull final Consumer<? super R> consumer) { Objects.requireNonNull(consumer); return (value1, value2, value3) -> consumer.accept(apply(value1, value2, value3)); }
From source file:org.geoserver.qos.BaseQosXmlEncoder.java
public void encodeRequestParameterConstraint(Translator tx, String name, Consumer<Void> valuesCallback) { final String reqParamConstTag = "qos:RequestParameterConstraint"; AttributesBuilder ab = new AttributesBuilder(); ab.add("name", name); tx.start(reqParamConstTag, ab.getAttributes()); final String allowedValuesTag = owsPrefix() + ":AllowedValues"; tx.start(allowedValuesTag);/*from ww w . ja v a 2s . c o m*/ valuesCallback.accept(null); tx.end(allowedValuesTag); tx.end(reqParamConstTag); }
From source file:at.gridtec.lambda4j.function.tri.TriIntFunction.java
/** * Returns a composed {@link TriIntConsumer} 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 TriIntConsumer} 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 www.j av a 2 s . co m*/ @Nonnull default TriIntConsumer consume(@Nonnull final Consumer<? super R> consumer) { Objects.requireNonNull(consumer); return (value1, value2, value3) -> consumer.accept(apply(value1, value2, value3)); }
From source file:at.gridtec.lambda4j.function.tri.TriLongFunction.java
/** * Returns a composed {@link TriLongConsumer} 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 TriLongConsumer} 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 . c o m @Nonnull default TriLongConsumer consume(@Nonnull final Consumer<? super R> consumer) { Objects.requireNonNull(consumer); return (value1, value2, value3) -> consumer.accept(apply(value1, value2, value3)); }
From source file:at.gridtec.lambda4j.function.tri.TriFloatFunction.java
/** * Returns a composed {@link TriFloatConsumer} 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 TriFloatConsumer} 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. ja v a 2s.co m*/ @Nonnull default TriFloatConsumer consume(@Nonnull final Consumer<? super R> consumer) { Objects.requireNonNull(consumer); return (value1, value2, value3) -> consumer.accept(apply(value1, value2, value3)); }