/** * Find the first annotation name for the given stereotype. * * @param stereotype The stereotype * @return The annotation name */ default @Nonnull Optional<String> getAnnotationNameByStereotype(@Nullable String stereotype) { return getAnnotationNamesByStereotype(stereotype).stream().findFirst(); }
@Override default @Nonnull List<String> getAnnotationNamesByStereotype(String stereotype) { return getAnnotationMetadata().getAnnotationNamesByStereotype(stereotype); }
/** * Resolve all of the annotation names that feature the given stereotype. * * @param stereotype The annotation names * @return A set of annotation names */ default @Nonnull List<String> getAnnotationNamesByStereotype(@Nonnull Class<? extends Annotation> stereotype) { ArgumentUtils.requireNonNull("stereotype", stereotype); return getAnnotationNamesByStereotype(stereotype.getName()); }
@Override default @Nonnull List<String> getAnnotationNamesByStereotype(@Nonnull Class<? extends Annotation> stereotype) { return getAnnotationMetadata().getAnnotationNamesByStereotype(stereotype); }
/** * Resolve all of the annotation names that feature the given stereotype. * * @param stereotype The annotation names * @return A set of annotation names */ default @Nonnull List<Class<? extends Annotation>> getAnnotationTypesByStereotype(@Nonnull Class<? extends Annotation> stereotype) { ArgumentUtils.requireNonNull("stereotype", stereotype); List<String> names = getAnnotationNamesByStereotype(stereotype.getName()); return names.stream().map(this::getAnnotationType) .filter(Optional::isPresent) .map(opt -> (Class<? extends Annotation>) opt.get()) .collect(Collectors.toList()); }
@Override public boolean isPrototype(@Nonnull String name) throws NoSuchBeanDefinitionException { if (super.containsSingleton(name)) { return false; } final BeanDefinitionReference<?> definition = beanDefinitionMap.get(name); if (definition != null) { final AnnotationMetadata annotationMetadata = definition.getAnnotationMetadata(); if (annotationMetadata.hasDeclaredStereotype(Prototype.class)) { return true; } else { final boolean hasScope = annotationMetadata.getAnnotationNamesByStereotype(Scope.class).isEmpty(); return !hasScope; } } return false; }