List of usage examples for java.util.function Consumer accept
void accept(T t);
From source file:org.apache.tinkerpop.gremlin.neo4j.BaseNeo4jGraphTest.java
protected void tryCommit(final Neo4jGraph g, final Consumer<Neo4jGraph> assertFunction) { assertFunction.accept(g); if (g.features().graph().supportsTransactions()) { g.tx().commit();/*from w ww . ja va 2 s . c om*/ assertFunction.accept(g); } }
From source file:com.lithium.flow.io.InputStreamSpliterator.java
@Override public boolean tryAdvance(@Nonnull Consumer<? super String> action) { if (it.hasNext()) { action.accept(it.nextLine()); return true; } else {//from w ww .j a v a 2 s.c o m it.close(); return false; } }
From source file:io.pivotal.strepsirrhini.chaosloris.docs.AbstractApiDocumentation.java
protected final String createPages(Consumer<Integer> pageCreator) { for (int i = 0; i < 12; i++) { pageCreator.accept(i); }// w w w . ja v a2s . co m return "?page=2&size=3"; }
From source file:com.lithium.flow.util.JedisPooler.java
public void accept(@Nonnull Consumer<Jedis> consumer) { checkNotNull(consumer);// www . j ava2 s .co m try (Jedis jedis = getResource()) { consumer.accept(jedis); } }
From source file:io.syndesis.jsondb.impl.JsonRecordSupport.java
public static void jsonStreamToRecords(JsonParser jp, String path, Consumer<JsonRecord> consumer) throws IOException { boolean inArray = false; int arrayIndex = 0; while (true) { JsonToken nextToken = jp.nextToken(); String currentPath = path; if (nextToken == FIELD_NAME) { if (inArray) { currentPath = path + toArrayIndexPath(arrayIndex) + "/"; }/*from www. java 2s. c om*/ jsonStreamToRecords(jp, currentPath + validateKey(jp.getCurrentName()) + "/", consumer); } else if (nextToken == VALUE_NULL) { if (inArray) { currentPath = path + toArrayIndexPath(arrayIndex) + "/"; } consumer.accept(JsonRecord.of(currentPath, "", nextToken.id())); if (inArray) { arrayIndex++; } else { return; } } else if (nextToken.isScalarValue()) { if (inArray) { currentPath = path + toArrayIndexPath(arrayIndex) + "/"; } consumer.accept(JsonRecord.of(currentPath, jp.getValueAsString(), nextToken.id())); if (inArray) { arrayIndex++; } else { return; } } else if (nextToken == END_OBJECT) { if (inArray) { arrayIndex++; } else { return; } } else if (nextToken == START_ARRAY) { inArray = true; } else if (nextToken == END_ARRAY) { return; } } }
From source file:alfio.model.result.Result.java
public void ifSuccess(Consumer<T> consumer) { if (isSuccess()) { consumer.accept(data); } }
From source file:com.centurylink.cloud.sdk.core.exceptions.ErrorsContainer.java
public <T> Consumer<T> intercept(Consumer<T> func) { return (T val) -> { try {/* ww w . j a v a 2 s. c o m*/ func.accept(val); } catch (ClcException ex) { errors.add(ex); } }; }
From source file:blusunrize.immersiveengineering.api.ApiUtils.java
public static void callFromOtherThread(Consumer<Runnable> cons, Runnable r) { new Thread(() -> cons.accept(r)).start(); }
From source file:org.beryx.viewreka.fxui.settings.FxPropsManager.java
public void applySettings() { propsMap.forEach((key, propPair) -> { Object value = settings.getProperty(key, null, true); if (value != null) { try { Consumer<Object> consumer = (Consumer<Object>) propPair.getKey(); consumer.accept(value); } catch (Exception e) { log.warn("Cannot apply value '" + value + "' to '" + key + "'", e); }/*from w ww . ja v a 2s. co m*/ } }); }
From source file:co.degraph.server.acceptance.api.controllers.GraphResourceChecks.java
public GraphResourceChecks hasNode(String id, Consumer<NodeResourceChecks> nodeCheck) { NodeResource node = find(getValue().getNodes(), n -> id.equals(n.getId())); nodeCheck.accept(new NodeResourceChecks(node)); return this; }