/** * Returns a composed {@link MethodLookup} that represents a concatenation of this predicate and another. When * evaluating the composed method lookup, if this lookup evaluates {@code true}, then the {@code other} method lookup * is not evaluated. * * @param other must not be {@literal null}. * @return the composed {@link MethodLookup}. */ default MethodLookup and(MethodLookup other) { Assert.notNull(other, "Other method lookup must not be null!"); return () -> Stream.concat(getLookups().stream(), other.getLookups().stream()).collect(Collectors.toList()); }
private static Optional<Method> findMethod(InvokedMethod invokedMethod, MethodLookup lookup, Supplier<Stream<Method>> methodStreamSupplier) { for (MethodPredicate methodPredicate : lookup.getLookups()) { Optional<Method> resolvedMethod = methodStreamSupplier.get() .filter(it -> methodPredicate.test(invokedMethod, it)) // .findFirst(); if (resolvedMethod.isPresent()) { return resolvedMethod; } } return Optional.empty(); }