@Override default <T extends Annotation> Optional<AnnotationValue<T>> findDeclaredAnnotation(Class<T> annotationClass) { return getAnnotationMetadata().findDeclaredAnnotation(annotationClass); } }
@Override default <T extends Annotation> Optional<AnnotationValue<T>> findDeclaredAnnotation(String annotation) { return getAnnotationMetadata().findDeclaredAnnotation(annotation); }
@Override default @Nonnull <T extends Annotation> Optional<AnnotationValue<T>> findDeclaredAnnotation(@Nonnull Class<T> annotationClass) { return getAnnotationMetadata().findDeclaredAnnotation(annotationClass); }
/** * {@inheritDoc} */ @Override default @Nonnull <T extends Annotation> Optional<AnnotationValue<T>> findDeclaredAnnotation(@Nonnull Class<T> annotationClass) { ArgumentUtils.requireNonNull("annotationClass", annotationClass); Repeatable repeatable = annotationClass.getAnnotation(Repeatable.class); if (repeatable != null) { List<AnnotationValue<T>> values = getDeclaredAnnotationValuesByType(annotationClass); if (!values.isEmpty()) { return Optional.of(values.iterator().next()); } else { return Optional.empty(); } } else { return this.findDeclaredAnnotation(annotationClass.getName()); } }
@Override public <BT extends BeanType<T>> Stream<BT> reduce(Class<T> beanType, Stream<BT> candidates) { check("beanType", beanType).notNull(); check("candidates", candidates).notNull(); return candidates.filter(candidate -> { if (!beanType.isAssignableFrom(candidate.getBeanType())) { return false; } String typeName; AnnotationMetadata annotationMetadata = candidate.getAnnotationMetadata(); // here we resolved the declared Qualifier of the bean Optional<String> beanQualifier = annotationMetadata.findDeclaredAnnotation(Named.class).flatMap(namedAnnotationValue -> namedAnnotationValue.getValue(String.class)); typeName = beanQualifier.orElseGet(() -> { if (candidate instanceof NameResolver) { Optional<String> resolvedName = ((NameResolver) candidate).resolveName(); return resolvedName.orElse(candidate.getBeanType().getSimpleName()); } return candidate.getBeanType().getSimpleName(); }); return typeName.equalsIgnoreCase(name) || typeName.equalsIgnoreCase(name + beanType.getSimpleName()); } ); }
@Override public <BT extends BeanType<T>> Stream<BT> reduce(Class<T> beanType, Stream<BT> candidates) { check("beanType", beanType).notNull(); check("candidates", candidates).notNull(); return candidates.filter(candidate -> { if (!beanType.isAssignableFrom(candidate.getBeanType())) { return false; } String typeName; AnnotationMetadata annotationMetadata = candidate.getAnnotationMetadata(); // here we resolved the declared Qualifier of the bean Optional<String> beanQualifier = annotationMetadata.findDeclaredAnnotation(Named.class).flatMap(namedAnnotationValue -> namedAnnotationValue.getValue(String.class)); typeName = beanQualifier.orElseGet(() -> { if (candidate instanceof NameResolver) { Optional<String> resolvedName = ((NameResolver) candidate).resolveName(); return resolvedName.orElse(candidate.getBeanType().getSimpleName()); } return candidate.getBeanType().getSimpleName(); }); return typeName.equalsIgnoreCase(name) || typeName.equalsIgnoreCase(name + beanType.getSimpleName()); } ); }