org.springframework.data.util.Optionals Java Examples
The following examples show how to use
org.springframework.data.util.Optionals.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultQueryHints.java From specification-with-projection with MIT License | 5 votes |
private Map<String, Object> getFetchGraphs() { return Optionals .mapIfAllPresent(entityManager, metadata.getEntityGraph(), (em, graph) -> Jpa21Utils.tryGetFetchGraphHints(em, getEntityGraph(graph), information.getJavaType())) .orElse(Collections.emptyMap()); }
Example #2
Source File: InventoryOrderEventListener.java From salespoint with Apache License 2.0 | 5 votes |
private Stream<UniqueInventoryItem> updateStockFor(OrderLine orderLine) { var productIdentifier = orderLine.getProductIdentifier(); var item = uniqueInventory.findByProductIdentifier(productIdentifier) .map(it -> it.increaseQuantity(orderLine.getQuantity())); if (!item.isPresent() && inventory.findByProductIdentifier(productIdentifier).isEmpty()) { throw new IllegalArgumentException( String.format("Couldn't find InventoryItem for product %s!", productIdentifier)); } return Optionals.toStream(item); }
Example #3
Source File: AnnotationAuditingMetadata.java From spring-data-mybatis with Apache License 2.0 | 4 votes |
/** * Returns whether the {@link Class} represented in this instance is auditable or not. */ public boolean isAuditable() { return Optionals.isAnyPresent(createdByField, createdDateField, lastModifiedByField, lastModifiedDateField); }