private Map<String, Object> getFetchGraphs() { return Optionals .mapIfAllPresent(entityManager, metadata.getEntityGraph(), (em, graph) -> Jpa21Utils.tryGetFetchGraphHints(em, getEntityGraph(graph), information.getJavaType())) .orElse(Collections.emptyMap()); }
/** * Invokes the given {@link BiConsumer} if all given {@link Optional} are present. * * @param left must not be {@literal null}. * @param right must not be {@literal null}. * @param consumer must not be {@literal null}. */ public static <T, S> void ifAllPresent(Optional<T> left, Optional<S> right, BiConsumer<T, S> consumer) { Assert.notNull(left, "Optional must not be null!"); Assert.notNull(right, "Optional must not be null!"); Assert.notNull(consumer, "Consumer must not be null!"); mapIfAllPresent(left, right, (l, r) -> { consumer.accept(l, r); return null; }); }
public int compareTo(@Nullable Revision<N, ?> that) { if (that == null) { return 1; } return mapIfAllPresent(getRevisionNumber(), that.getRevisionNumber(), // (left, right) -> left.compareTo(right)).orElse(-1); }
/** * Creates a {@link RepositoryInvoker} for the repository managing the given domain type. * * @param domainType * @return */ private RepositoryInvoker prepareInvokers(Class<?> domainType) { Optional<RepositoryInformation> information = repositories.getRepositoryInformationFor(domainType); Optional<Object> repository = repositories.getRepositoryFor(domainType); return mapIfAllPresent(information, repository, this::createInvoker)// .orElseThrow( () -> new IllegalArgumentException(String.format("No repository found for domain type: %s", domainType))); }
private Map<String, Object> getFetchGraphs() { return Optionals .mapIfAllPresent(entityManager, metadata.getEntityGraph(), (em, graph) -> Jpa21Utils.tryGetFetchGraphHints(em, getEntityGraph(graph), information.getJavaType())) .orElse(Collections.emptyMap()); }