private O createOperation(EndpointId endpointId, Object target, Method method) { return OPERATION_TYPES.entrySet().stream() .map((entry) -> createOperation(endpointId, target, method, entry.getKey(), entry.getValue())) .filter(Objects::nonNull).findFirst().orElse(null); }
private O createOperation(EndpointId endpointId, Object target, Method method, OperationType operationType, Class<? extends Annotation> annotationType) { AnnotationAttributes annotationAttributes = AnnotatedElementUtils .getMergedAnnotationAttributes(method, annotationType); if (annotationAttributes == null) { return null; } DiscoveredOperationMethod operationMethod = new DiscoveredOperationMethod(method, operationType, annotationAttributes); OperationInvoker invoker = new ReflectiveOperationInvoker(target, operationMethod, this.parameterValueMapper); invoker = applyAdvisors(endpointId, operationMethod, invoker); return createOperation(endpointId, operationMethod, invoker); }
private void addOperations(MultiValueMap<OperationKey, O> indexed, EndpointId id, Object target, boolean replaceLast) { Set<OperationKey> replacedLast = new HashSet<>(); Collection<O> operations = this.operationsFactory.createOperations(id, target); for (O operation : operations) { OperationKey key = createOperationKey(operation); O last = getLast(indexed.get(key)); if (replaceLast && replacedLast.add(key) && last != null) { indexed.get(key).remove(last); } indexed.add(key, operation); } }
public Collection<O> createOperations(EndpointId id, Object target) { return MethodIntrospector.selectMethods(target.getClass(), (MetadataLookup<O>) (method) -> createOperation(id, target, method)) .values(); }