@Override public <A extends Annotation> A getAnnotation(final Class<A> annotation) { return annotated.getAnnotation(annotation); }
@Override public Annotation[] getAnnotations() { return annotated.getAnnotations(); }
@Override public boolean isAnnotationPresent(final Class<? extends Annotation> annotation) { return annotated.isAnnotationPresent(annotation); }
private Predicate<List<InjectableHandle>> getPathPredicate(final HasAnnotations annotated, final List<String> problems) { if (annotated.isAnnotationPresent(Typed.class)) { final Class<?>[] beanTypes = annotated.getAnnotation(Typed.class).value(); validateAssignableTypes(annotated, beanTypes, problems); return path -> Object.class.getName().equals(path.get(0)) || Arrays.stream(beanTypes) .anyMatch(beanType -> path.get(0).getType().getFullyQualifiedName().equals(beanType.getName())); } else { return ANY; } }
protected Collection<Annotation> getQualifiers(final HasAnnotations injectedType) { final Collection<Annotation> annos = new ArrayList<>(); for (final Annotation anno : injectedType.getAnnotations()) { if (anno.annotationType().isAnnotationPresent(Qualifier.class)) { annos.add(anno); } } return annos; }
@Override public boolean isAnnotationPresent(final Class<? extends Annotation> annotation) { return getAnnotated().isAnnotationPresent(annotation); }
public default boolean isAnnotationPresent(final Class<? extends Annotation> annotation) { return getAnnotation(annotation) != null; }
public static List<Annotation> extractQualifiers(final HasAnnotations annotated) { final List<Annotation> qualifiers = new ArrayList<Annotation>(); for (final Annotation anno : annotated.getAnnotations()) { if (anno.annotationType().isAnnotationPresent(Qualifier.class)) { qualifiers.add(anno); } } return qualifiers; }
private WiringElementType[] getWiringTypeForProducer(final MetaClass enclosingClass, final HasAnnotations annotated, final Class<? extends Annotation> directScope) { final List<WiringElementType> wiringTypes = new ArrayList<>(); wiringTypes.addAll(getWiringTypesForScopeAnnotation(directScope)); if (annotated.isAnnotationPresent(Specializes.class)) { wiringTypes.add(WiringElementType.Specialization); } if (enclosingClass.isAnnotationPresent(LoadAsync.class)) { wiringTypes.add(WiringElementType.LoadAsync); } return wiringTypes.toArray(new WiringElementType[wiringTypes.size()]); }
public default boolean isAnnotationPresent(final Class<? extends Annotation> annotation) { return getAnnotation(annotation) != null; }
@SuppressWarnings("unchecked") public default <A extends Annotation> A getAnnotation(final Class<A> annotation) { // Please no hate or else null. return (A) Arrays.stream(getAnnotations()) .filter(a -> a.annotationType().equals(annotation)) .findFirst() .orElse(null); } }
if (componentType.isAssignableTo(Widget.class)) { if (!decorable.get().isAnnotationPresent(Inject.class) && decorable.decorableType().equals(DecorableType.FIELD) && componentType.isDefaultInstantiable()) { Statement widgetInit = Stmt.loadVariable("this").invoke( PrivateAccessUtil.getPrivateFieldAccessorName(decorable.getAsField()),
public static AbstractStatementBuilder getAssignableTypesArrayStmt(final Injectable injectable) { final Object[] assignableTypes = injectable.getAnnotatedObject() .flatMap(annotated -> Optional.ofNullable(annotated.getAnnotation(Typed.class))) .map(typedAnno -> typedAnno.value()) // Ensure that Object is an assignable type .map(beanTypes -> { if (Arrays.stream(beanTypes).anyMatch(type -> Object.class.equals(type))) { return (Object[]) beanTypes; } else { final Class<?>[] copyWithObject = Arrays.copyOf(beanTypes, beanTypes.length+1); copyWithObject[beanTypes.length] = Object.class; return (Object[]) copyWithObject; } }) .orElseGet(() -> getAllAssignableTypes(injectable.getInjectedType()).stream().filter(MetaClass::isPublic).toArray()); return newArray(Class.class).initialize(assignableTypes); }
@SuppressWarnings("unchecked") public default <A extends Annotation> A getAnnotation(final Class<A> annotation) { // Please no hate or else null. return (A) Arrays.stream(getAnnotations()) .filter(a -> a.annotationType().equals(annotation)) .findFirst() .orElse(null); } }
if (componentType.isAssignableTo(Widget.class)) { if (!decorable.get().isAnnotationPresent(Inject.class) && decorable.decorableType().equals(DecorableType.FIELD) && componentType.isDefaultInstantiable()) { Statement widgetInit = Stmt.loadVariable("this").invoke( PrivateAccessUtil.getPrivateFieldAccessorName(decorable.getAsField()),
decorator.getClass().getAnnotation(CodeDecorator.class).order(), elemType, () -> { final Decorable decorable = new Decorable(annotated, annotated.getAnnotation(annoType), Decorable.DecorableType.fromElementType(elemType), injectionContext, builder.getClassDefinition().getContext(), builder.getClassDefinition(), injectable);
@Override public Annotation[] getAnnotations() { return getAnnotated().getAnnotations(); }
public Annotation getMatchingAnnotationForElementType(final WiringElementType type, final HasAnnotations hasAnnotations) { final Collection<Class<? extends Annotation>> annotationsForElementType = getAnnotationsForElementType(type); for (final Annotation a : hasAnnotations.getAnnotations()) { if (annotationsForElementType.contains(a.annotationType())) { return a; } } final Set<Annotation> annotationSet = new HashSet<Annotation>(); fillInStereotypes(annotationSet, hasAnnotations.getAnnotations(), false); for (final Annotation a : annotationSet) { if (annotationsForElementType.contains(a.annotationType())) { return a; } } return null; }
private SortedSet<AnnotationWrapper> getRawQualifiers(final HasAnnotations annotated) { final SortedSet<AnnotationWrapper> annos = new TreeSet<>(); for (final Annotation anno : annotated.getAnnotations()) { if (anno.annotationType().isAnnotationPresent(javax.inject.Qualifier.class)) { if (anno.annotationType().equals(Named.class) && ((Named) anno).value().equals("")) { annos.add(createNamed(annotated)); } else { annos.add(new AnnotationWrapper(anno)); } } else if (anno.annotationType().isAnnotationPresent(Stereotype.class)) { annos.addAll(getRawQualifiers(MetaClassFactory.get(anno.annotationType()))); } } return annos; }
}); for (final Annotation anno : annotated.getAnnotations()) { final Class<? extends Annotation> annoType = anno.annotationType(); if (scopeAnnoTypes.contains(annoType)) {