@Override public List<MethodPredicate> getLookups() { MethodPredicate detailedComparison = (invoked, candidate) -> Optional.of(candidate) .filter(baseClassMethod -> baseClassMethod.getName().equals(invoked.getName()))// Right name .filter(baseClassMethod -> baseClassMethod.getParameterCount() == invoked.getParameterCount()) .filter(baseClassMethod -> parametersMatch(invoked.getMethod(), baseClassMethod))// All parameters match .isPresent(); return Collections.singletonList(detailedComparison); }
/** * Direct method lookup filtering on exact method name, parameter count and parameter types. * * @return direct method lookup. */ public static MethodLookup direct() { MethodPredicate direct = (invoked, candidate) -> candidate.getName().equals(invoked.getName()) && candidate.getParameterCount() == invoked.getParameterCount() && Arrays.equals(candidate.getParameterTypes(), invoked.getParameterTypes()); return () -> Collections.singletonList(direct); }
/** * Returns a candidate method from the base class for the given one or the method given in the first place if none * one the base class matches. * * @param method must not be {@literal null}. * @param baseClass must not be {@literal null}. * @param predicate must not be {@literal null}. * @return */ private static Optional<Method> getMethodCandidate(InvokedMethod invokedMethod, Method candidate, Predicate<ParameterOverrideCriteria> predicate) { return Optional.of(candidate)// .filter(it -> invokedMethod.getName().equals(it.getName()))// .filter(it -> invokedMethod.getParameterCount() == it.getParameterCount())// .filter(it -> parametersMatch(it, invokedMethod.getMethod(), predicate)); }
/** * Returns a candidate method from the base class for the given one or the method given in the first place if none * one the base class matches. * * @param method must not be {@literal null}. * @param baseClass must not be {@literal null}. * @param predicate must not be {@literal null}. * @return */ private static Optional<Method> getMethodCandidate(InvokedMethod invokedMethod, Method candidate, Predicate<ParameterOverrideCriteria> predicate) { return Optional.of(candidate)// .filter(it -> invokedMethod.getName().equals(it.getName()))// .filter(it -> invokedMethod.getParameterCount() == it.getParameterCount())// .filter(it -> parametersMatch(it, invokedMethod.getMethod(), predicate)); }
/** * Returns a candidate method from the base class for the given one or the method given in the first place if none * one the base class matches. * * @param method must not be {@literal null}. * @param baseClass must not be {@literal null}. * @param predicate must not be {@literal null}. * @return */ private static Optional<Method> getMethodCandidate(InvokedMethod invokedMethod, Method candidate, Predicate<ParameterOverrideCriteria> predicate) { return Optional.of(candidate)// .filter(it -> invokedMethod.getName().equals(it.getName()))// .filter(it -> invokedMethod.getParameterCount() == it.getParameterCount())// .filter(it -> parametersMatch(it, invokedMethod.getMethod(), predicate)); }
/** * Returns a candidate method from the base class for the given one or the method given in the first place if none * one the base class matches. * * @param method must not be {@literal null}. * @param baseClass must not be {@literal null}. * @param predicate must not be {@literal null}. * @return */ private static Optional<Method> getMethodCandidate(InvokedMethod invokedMethod, Method candidate, Predicate<ParameterOverrideCriteria> predicate) { return Optional.of(candidate)// .filter(it -> invokedMethod.getName().equals(it.getName()))// .filter(it -> invokedMethod.getParameterCount() == it.getParameterCount())// .filter(it -> parametersMatch(it, invokedMethod.getMethod(), predicate)); }
/** * Returns a candidate method from the base class for the given one or the method given in the first place if none * one the base class matches. * * @param method must not be {@literal null}. * @param baseClass must not be {@literal null}. * @param predicate must not be {@literal null}. * @return */ private static Optional<Method> getMethodCandidate(InvokedMethod invokedMethod, Method candidate, Predicate<ParameterOverrideCriteria> predicate) { return Optional.of(candidate)// .filter(it -> invokedMethod.getName().equals(it.getName()))// .filter(it -> invokedMethod.getParameterCount() == it.getParameterCount())// .filter(it -> parametersMatch(it, invokedMethod.getMethod(), predicate)); }
/** * Returns a candidate method from the base class for the given one or the method given in the first place if none * one the base class matches. * * @param method must not be {@literal null}. * @param baseClass must not be {@literal null}. * @param predicate must not be {@literal null}. * @return */ private static Optional<Method> getMethodCandidate(InvokedMethod invokedMethod, Method candidate, Predicate<ParameterOverrideCriteria> predicate) { return Optional.of(candidate)// .filter(it -> invokedMethod.getName().equals(it.getName()))// .filter(it -> invokedMethod.getParameterCount() == it.getParameterCount())// .filter(it -> parametersMatch(it, invokedMethod.getMethod(), predicate)); }
@Override public List<MethodPredicate> getLookups() { MethodPredicate convertibleComparison = (invokedMethod, candidate) -> { List<Supplier<Optional<Method>>> suppliers = new ArrayList<>(); if (usesParametersWithReactiveWrappers(invokedMethod.getMethod())) { suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, assignableWrapperMatch())); // suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, wrapperConversionMatch())); } return suppliers.stream().anyMatch(supplier -> supplier.get().isPresent()); }; MethodPredicate detailedComparison = (invokedMethod, candidate) -> getMethodCandidate(invokedMethod, candidate, matchParameterOrComponentType(repositoryMetadata.getRepositoryInterface())).isPresent(); return Arrays.asList(convertibleComparison, detailedComparison); }
@Override public List<MethodPredicate> getLookups() { MethodPredicate convertibleComparison = (invokedMethod, candidate) -> { List<Supplier<Optional<Method>>> suppliers = new ArrayList<>(); if (usesParametersWithReactiveWrappers(invokedMethod.getMethod())) { suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, assignableWrapperMatch())); // suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, wrapperConversionMatch())); } return suppliers.stream().anyMatch(supplier -> supplier.get().isPresent()); }; MethodPredicate detailedComparison = (invokedMethod, candidate) -> getMethodCandidate(invokedMethod, candidate, matchParameterOrComponentType(repositoryMetadata.getRepositoryInterface())).isPresent(); return Arrays.asList(convertibleComparison, detailedComparison); }
@Override public List<MethodPredicate> getLookups() { MethodPredicate convertibleComparison = (invokedMethod, candidate) -> { List<Supplier<Optional<Method>>> suppliers = new ArrayList<>(); if (usesParametersWithReactiveWrappers(invokedMethod.getMethod())) { suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, assignableWrapperMatch())); // suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, wrapperConversionMatch())); } return suppliers.stream().anyMatch(supplier -> supplier.get().isPresent()); }; MethodPredicate detailedComparison = (invokedMethod, candidate) -> getMethodCandidate(invokedMethod, candidate, matchParameterOrComponentType(repositoryMetadata.getRepositoryInterface())).isPresent(); return Arrays.asList(convertibleComparison, detailedComparison); }
@Override public List<MethodPredicate> getLookups() { MethodPredicate convertibleComparison = (invokedMethod, candidate) -> { List<Supplier<Optional<Method>>> suppliers = new ArrayList<>(); if (usesParametersWithReactiveWrappers(invokedMethod.getMethod())) { suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, assignableWrapperMatch())); // suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, wrapperConversionMatch())); } return suppliers.stream().anyMatch(supplier -> supplier.get().isPresent()); }; MethodPredicate detailedComparison = (invokedMethod, candidate) -> getMethodCandidate(invokedMethod, candidate, matchParameterOrComponentType(repositoryMetadata.getRepositoryInterface())).isPresent(); return Arrays.asList(convertibleComparison, detailedComparison); }
@Override public List<MethodPredicate> getLookups() { MethodPredicate convertibleComparison = (invokedMethod, candidate) -> { List<Supplier<Optional<Method>>> suppliers = new ArrayList<>(); if (usesParametersWithReactiveWrappers(invokedMethod.getMethod())) { suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, assignableWrapperMatch())); // suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, wrapperConversionMatch())); } return suppliers.stream().anyMatch(supplier -> supplier.get().isPresent()); }; MethodPredicate detailedComparison = (invokedMethod, candidate) -> getMethodCandidate(invokedMethod, candidate, matchParameterOrComponentType(repositoryMetadata.getRepositoryInterface())).isPresent(); return Arrays.asList(convertibleComparison, detailedComparison); }
@Override public List<MethodPredicate> getLookups() { MethodPredicate convertibleComparison = (invokedMethod, candidate) -> { List<Supplier<Optional<Method>>> suppliers = new ArrayList<>(); if (usesParametersWithReactiveWrappers(invokedMethod.getMethod())) { suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, assignableWrapperMatch())); // suppliers.add(() -> getMethodCandidate(invokedMethod, candidate, wrapperConversionMatch())); } return suppliers.stream().anyMatch(supplier -> supplier.get().isPresent()); }; MethodPredicate detailedComparison = (invokedMethod, candidate) -> getMethodCandidate(invokedMethod, candidate, matchParameterOrComponentType(repositoryMetadata.getRepositoryInterface())).isPresent(); return Arrays.asList(convertibleComparison, detailedComparison); }
/** * Find the implementation method for the given {@link Method} invoked on the composite interface. * * @param method must not be {@literal null}. * @return */ public Optional<Method> findMethod(Method method) { return methodCache.computeIfAbsent(method, key -> RepositoryFragments.findMethod(InvokedMethod.of(key), methodLookup, fragments::methods)); }
@Override public List<MethodPredicate> getLookups() { MethodPredicate detailedComparison = (invoked, candidate) -> Optional.of(candidate) .filter(baseClassMethod -> baseClassMethod.getName().equals(invoked.getName()))// Right name .filter(baseClassMethod -> baseClassMethod.getParameterCount() == invoked.getParameterCount()) .filter(baseClassMethod -> parametersMatch(invoked.getMethod(), baseClassMethod))// All parameters match .isPresent(); return Collections.singletonList(detailedComparison); }
/** * Direct method lookup filtering on exact method name, parameter count and parameter types. * * @return direct method lookup. */ public static MethodLookup direct() { MethodPredicate direct = (invoked, candidate) -> candidate.getName().equals(invoked.getName()) && candidate.getParameterCount() == invoked.getParameterCount() && Arrays.equals(candidate.getParameterTypes(), invoked.getParameterTypes()) && candidate.getReturnType().equals(invoked.getMethod().getReturnType()); return () -> Collections.singletonList(direct); }
@Override public List<MethodPredicate> getLookups() { MethodPredicate detailedComparison = (invoked, candidate) -> Optional.of(candidate) .filter(baseClassMethod -> baseClassMethod.getName().equals(invoked.getName()))// Right name .filter(baseClassMethod -> baseClassMethod.getParameterCount() == invoked.getParameterCount()) .filter(baseClassMethod -> parametersMatch(invoked.getMethod(), baseClassMethod))// All parameters match .isPresent(); return Collections.singletonList(detailedComparison); }
/** * Direct method lookup filtering on exact method name, parameter count and parameter types. * * @return direct method lookup. */ public static MethodLookup direct() { MethodPredicate direct = (invoked, candidate) -> candidate.getName().equals(invoked.getName()) && candidate.getParameterCount() == invoked.getParameterCount() && Arrays.equals(candidate.getParameterTypes(), invoked.getParameterTypes()) && candidate.getReturnType().equals(invoked.getMethod().getReturnType()); return () -> Collections.singletonList(direct); }
@Override public List<MethodPredicate> getLookups() { MethodPredicate detailedComparison = (invoked, candidate) -> Optional.of(candidate) .filter(baseClassMethod -> baseClassMethod.getName().equals(invoked.getName()))// Right name .filter(baseClassMethod -> baseClassMethod.getParameterCount() == invoked.getParameterCount()) .filter(baseClassMethod -> parametersMatch(invoked.getMethod(), baseClassMethod))// All parameters match .isPresent(); return Collections.singletonList(detailedComparison); }