List of usage examples for java.util.function Consumer accept
void accept(T t);
From source file:com.github.erchu.beancp.DeclarativeMapImpl.java
@Override public <SI, DI> DeclarativeMap<S, D> mapInner(final Supplier<SI> supplierFunction, final Consumer<DI> toMember, final Supplier<DI> toMemberGetter, final Class<DI> toMemberClass, final BindingOption<S, D, DI>... options) { notNull(supplierFunction, "supplierFunction"); notNull(toMember, "toMember"); if (mode == MapMode.CONFIGURATION) { if (_afterMapExecuted) { throw new MapperConfigurationException(INVALID_STATEMENT_ORDER_MESSAGE); }/*from www .java 2s .com*/ _bindBindConstantOrMapExecuted = true; } if (mode == MapMode.EXECUTION) { SI currentSourceValue = supplierFunction.get(); if (currentSourceValue == null) { toMember.accept(null); } else { DI currentDestinationMemberValue; if (toMemberGetter == null) { currentDestinationMemberValue = null; } else { currentDestinationMemberValue = toMemberGetter.get(); } if (currentDestinationMemberValue == null) { DI mapResult = _executionPhaseMapper.map(currentSourceValue, toMemberClass); toMember.accept(mapResult); } else { _executionPhaseMapper.map(currentSourceValue, currentDestinationMemberValue); } } } return this; }
From source file:de.jackwhite20.japs.client.cache.impl.PubSubCacheImpl.java
@Override public <T> void getClass(String key, Consumer<T> consumer, Class<T> clazz) { if (key == null || key.isEmpty()) { throw new IllegalArgumentException("key cannot be null or empty"); }//from www . j a v a2s .c o m if (consumer == null) { throw new IllegalArgumentException("consumer cannot be null or empty"); } if (clazz == null) { throw new IllegalArgumentException("clazz cannot be null or empty"); } int id = CALLBACK_COUNTER.getAndIncrement(); // TODO: 14.06.2016 Maybe improve // Get the class as string and deserialize it callbacks.put(id, new Consumer<String>() { @Override public void accept(String s) { consumer.accept(gson.fromJson(s, clazz)); } }); JSONObject jsonObject = new JSONObject().put("op", OpCode.OP_CACHE_GET.getCode()).put("key", key).put("id", id); write(jsonObject); }
From source file:org.brickhouse.impl.SqlTable.java
@Override public void readAll(final Filter filter, final Consumer<HMap> consumer, boolean fillDii) { final Map<String, String> disCache = fillDii ? new HashMap<>() : null; long start = System.nanoTime(); final MutableInt count = new MutableInt(); final MutableInt included = new MutableInt(); try {// w w w . j ava 2 s. com jt.query(select, new RowCallbackHandler() { @Override public void processRow(ResultSet rs) throws SQLException { HMap map = toMap(rs.getString(1)); count.increment(); if (filter.include(map, pather)) { fillDii(map, disCache); consumer.accept(map); included.increment(); } } }); } catch (CancelReadException e) { // no op } if (stats) saveStats(filter.toString(), count.intValue(), included.intValue(), fillDii, System.nanoTime() - start, System.currentTimeMillis()); }
From source file:org.opencb.opencga.catalog.db.mongodb.CatalogMongoProjectDBAdaptor.java
@Override public void forEach(Query query, Consumer<? super Object> action, QueryOptions options) throws CatalogDBException { Objects.requireNonNull(action); CatalogDBIterator<Project> catalogDBIterator = iterator(query, options); while (catalogDBIterator.hasNext()) { action.accept(catalogDBIterator.next()); }// w w w . j a v a2 s . c om catalogDBIterator.close(); }
From source file:com.evolveum.midpoint.repo.sql.helpers.ObjectDeltaUpdater.java
private void processObjectExtensionValues(RObject object, Class<? extends ROExtValue> type, Consumer<Collection<ROExtValue>> processObjectValues) { if (type.equals(ROExtDate.class)) { processObjectValues.accept(object.getDates()); Short count = getCount(object.getDates()); object.setDatesCount(count);/* w ww . j a va2 s . c o m*/ } else if (type.equals(ROExtLong.class)) { processObjectValues.accept(object.getLongs()); Short count = getCount(object.getLongs()); object.setLongsCount(count); } else if (type.equals(ROExtReference.class)) { processObjectValues.accept(object.getReferences()); Short count = getCount(object.getReferences()); object.setReferencesCount(count); } else if (type.equals(ROExtString.class)) { processObjectValues.accept(object.getStrings()); Short count = getCount(object.getStrings()); object.setStringsCount(count); } else if (type.equals(ROExtPolyString.class)) { processObjectValues.accept(object.getPolys()); Short count = getCount(object.getPolys()); object.setPolysCount(count); } else if (type.equals(ROExtBoolean.class)) { processObjectValues.accept(object.getBooleans()); Short count = getCount(object.getBooleans()); object.setBooleansCount(count); } }
From source file:com._4dconcept.springframework.data.marklogic.core.MarklogicTemplate.java
private void doInSession(Consumer<Session> sessionTask) { Session session = ContentSourceUtils.getSession(contentSource); try {//w w w . j a v a 2s .co m sessionTask.accept(session); } finally { ContentSourceUtils.releaseSession(session, contentSource); } }
From source file:org.codice.ddf.catalog.ui.metacard.ListApplication.java
private void store(AttachmentInfo createInfo, Consumer<String> idConsumer, Consumer<String> errorMessageConsumer, Metacard metacard) { CreateStorageRequest streamCreateRequest = new CreateStorageRequestImpl( Collections.singletonList(new IncomingContentItem(uuidGenerator, createInfo.getStream(), createInfo.getContentType(), createInfo.getFilename(), metacard)), null);/*from ww w .j a v a2 s . c o m*/ try { CreateResponse createResponse = catalogFramework.create(streamCreateRequest); createResponse.getCreatedMetacards().stream().map(Metacard::getId).forEach(idConsumer); } catch (IngestException e) { String errorMessage = "Error while storing entry in catalog."; LOGGER.info(errorMessage, e); INGEST_LOGGER.warn(errorMessage, e); errorMessageConsumer.accept(errorMessage); } catch (SourceUnavailableException e) { String exceptionMessage = "Cannot create catalog entry because source is unavailable."; LOGGER.info(exceptionMessage, e); INGEST_LOGGER.warn(exceptionMessage, e); throw new InternalServerErrorException(exceptionMessage); } }
From source file:com.evolveum.midpoint.repo.sql.helpers.ObjectDeltaUpdater.java
private void processAssignmentExtensionValues(RAssignmentExtension extension, Class<? extends RAExtValue> type, Consumer<Collection<? extends RAExtValue>> processObjectValues) { if (type.equals(RAExtDate.class)) { processObjectValues.accept(extension.getDates()); Short count = getCount(extension.getDates()); extension.setDatesCount(count);/* w ww .j a v a 2 s. c om*/ } else if (type.equals(RAExtLong.class)) { processObjectValues.accept(extension.getLongs()); Short count = getCount(extension.getLongs()); extension.setLongsCount(count); } else if (type.equals(RAExtReference.class)) { processObjectValues.accept(extension.getReferences()); Short count = getCount(extension.getReferences()); extension.setReferencesCount(count); } else if (type.equals(RAExtString.class)) { processObjectValues.accept(extension.getStrings()); Short count = getCount(extension.getStrings()); extension.setStringsCount(count); } else if (type.equals(RAExtPolyString.class)) { processObjectValues.accept(extension.getPolys()); Short count = getCount(extension.getPolys()); extension.setPolysCount(count); } else if (type.equals(RAExtBoolean.class)) { processObjectValues.accept(extension.getBooleans()); Short count = getCount(extension.getBooleans()); extension.setBooleansCount(count); } }
From source file:org.icgc.dcc.portal.repository.FileRepository.java
private SearchResponse searchFileCentricPQL(String logMessage, StatementNode pqlAst, Consumer<SearchRequestBuilder> customizer) { val request = queryEngine.execute(pqlAst, FILE).getRequestBuilder(); customizer.accept(request); log.debug(logMessage + "; ES query is: '{}'", request); return request.execute().actionGet(); }
From source file:org.icgc.dcc.portal.repository.FileRepository.java
private SearchResponse searchFiles(String indexType, String logMessage, Consumer<SearchRequestBuilder> customizer) { val request = client.prepareSearch(repoIndexName).setTypes(indexType); customizer.accept(request); log.debug(logMessage + "; ES query is: '{}'", request); return request.execute().actionGet(); }