List of usage examples for java.util.function Consumer accept
void accept(T t);
From source file:at.gridtec.lambda4j.function.bi.BiDoubleFunction.java
/** * Returns a composed {@link BiDoubleConsumer} 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 BiDoubleConsumer} 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 a v a 2 s. c o m @Nonnull default BiDoubleConsumer consume(@Nonnull final Consumer<? super R> consumer) { Objects.requireNonNull(consumer); return (value1, value2) -> consumer.accept(apply(value1, value2)); }
From source file:org.opendatakit.briefcase.ui.settings.SettingsPanelForm.java
void onSendUsageDataChange(Consumer<Boolean> callback) { sendUsageDataField.addActionListener(__ -> callback.accept(sendUsageDataField.isSelected())); }
From source file:org.eclipse.packagedrone.utils.rpm.build.PayloadRecorder.java
public Result addSymbolicLink(final String targetPath, final String linkTo, final Consumer<CpioArchiveEntry> customizer) throws IOException { final byte[] bytes = linkTo.getBytes(StandardCharsets.UTF_8); final CpioArchiveEntry entry = new CpioArchiveEntry(targetPath); entry.setSize(bytes.length);/*from w w w . j a v a2 s . co m*/ if (customizer != null) { customizer.accept(entry); } this.archiveStream.putArchiveEntry(entry); this.archiveStream.write(bytes); this.archiveStream.closeArchiveEntry(); return new Result(bytes.length, null); }
From source file:org.opendatakit.briefcase.ui.settings.SettingsPanelForm.java
void onPullInParallelChange(Consumer<Boolean> callback) { pullInParallelField.addActionListener(__ -> callback.accept(pullInParallelField.isSelected())); }
From source file:org.opendatakit.briefcase.ui.settings.SettingsPanelForm.java
void onResumeLastPullChange(Consumer<Boolean> callback) { resumeLastPullField.addActionListener(__ -> callback.accept(resumeLastPullField.isSelected())); }
From source file:org.apache.tinkerpop.gremlin.process.traversal.Traversal.java
/** * A traversal can be rewritten such that its defined end type E may yield objects of a different type. * This helper method allows for the casting of the output to the known the type. * * @param endType the true output type of the traversal * @param consumer a {@link Consumer} to process each output * @param <E2> the known output type of the traversal *///from www . ja va 2s.c o m public default <E2> void forEachRemaining(final Class<E2> endType, final Consumer<E2> consumer) { try { while (true) { consumer.accept((E2) next()); } } catch (final NoSuchElementException ignore) { } }
From source file:org.opendatakit.briefcase.ui.settings.SettingsPanelForm.java
void onRememberPasswordsChange(Consumer<Boolean> callback) { rememberPasswordsField.addActionListener(__ -> callback.accept(rememberPasswordsField.isSelected())); }
From source file:org.apache.tinkerpop.gremlin.process.traversal.Traversal.java
@Override public default void forEachRemaining(final Consumer<? super E> action) { try {/*from w w w . j ava 2 s.c om*/ while (true) { action.accept(next()); } } catch (final NoSuchElementException ignore) { } }
From source file:org.commonjava.indy.folo.dto.TrackedContentEntryDTOTest.java
private void assertRoundTrip(final TrackedContentEntryDTO in, final Consumer<TrackedContentEntryDTO> extraAssertions) throws IOException { IndyObjectMapper mapper = new IndyObjectMapper(true); String json = mapper.writeValueAsString(in); TrackedContentEntryDTO out = mapper.readValue(json, TrackedContentEntryDTO.class); assertThat(out, notNullValue());//w w w . jav a 2 s . co m assertThat(out.getStoreKey(), equalTo(in.getStoreKey())); assertThat(out.getPath(), equalTo(in.getPath())); if (extraAssertions != null) { extraAssertions.accept(out); } assertThat(out, equalTo(in)); }
From source file:com.github.lburgazzoli.camel.CaseToIncidentProcessor.java
@SuppressWarnings("unchecked") private <T> boolean setIfDifferent(String fieldName, Supplier<T> oldValue, Supplier<T> newValue, Consumer<T> setter) { T o = oldValue != null ? oldValue.get() : null; T n = newValue != null ? newValue.get() : null; if (o instanceof String) { o = (T) StringUtils.trimToNull((String) o); }/* ww w.j a v a 2s. co m*/ if (n instanceof String) { n = (T) StringUtils.trimToNull((String) n); } if (!Objects.equals(o, n)) { LOGGER.debug("Update {} -> old: {}, new: {}", fieldName, o, n); setter.accept(n); return true; } else { return false; } }