private void checkMetaAnnotations(EnhancedAnnotation<T> annotatedAnnotation) { ElementType[] elementTypes = getTargetElementTypes(annotatedAnnotation.getAnnotation(Target.class)); for (Annotation inheritedBinding : getInheritedInterceptionBindingTypes()) { ElementType[] metaAnnotationElementTypes = getTargetElementTypes(inheritedBinding.annotationType().getAnnotation(Target.class)); if (!Arrays2.containsAll(metaAnnotationElementTypes, elementTypes)) { ReflectionLogger.LOG.invalidInterceptorBindingTargetDeclaration(inheritedBinding.annotationType().getName(), Arrays.toString(metaAnnotationElementTypes), annotatedAnnotation.getJavaClass().getName(), Arrays.toString(elementTypes)); } } }
private void checkArrayAndAnnotationValuedMembers(EnhancedAnnotation<T> annotatedAnnotation) { for (EnhancedAnnotatedMethod<?, ?> annotatedMethod : annotatedAnnotation.getMembers()) { if ((Reflections.isArrayType(annotatedMethod.getJavaClass()) || Annotation.class.isAssignableFrom(annotatedMethod.getJavaClass())) && !getNonBindingMembers().contains(annotatedMethod.slim())) { throw MetadataLogger.LOG.nonBindingMemberTypeException(annotatedMethod); } } }
/** * Validates the binding types */ private void checkBindings(EnhancedAnnotation<T> annotatedAnnotation) { Set<Annotation> bindings = annotatedAnnotation.getMetaAnnotations(Qualifier.class); if (bindings.size() > 0) { for (Annotation annotation : bindings) { if (!annotation.annotationType().equals(Named.class)) { throw MetadataLogger.LOG.qualifierOnStereotype(annotatedAnnotation); } } } }
/** * Initializes the bean name defaulted */ private void initBeanNameDefaulted(EnhancedAnnotation<T> annotatedAnnotation) { if (annotatedAnnotation.isAnnotationPresent(Named.class)) { if (!"".equals(annotatedAnnotation.getAnnotation(Named.class).value())) { throw MetadataLogger.LOG.valueOnNamedStereotype(annotatedAnnotation); } beanNameDefaulted = true; } }
protected void check(EnhancedAnnotation<T> annotatedAnnotation) { if (valid && (!annotatedAnnotation.isAnnotationPresent(Retention.class) || annotatedAnnotation.isAnnotationPresent(Retention.class) && !annotatedAnnotation.getAnnotation(Retention.class).value().equals(RetentionPolicy.RUNTIME))) { this.valid = false; ReflectionLogger.LOG.missingRetention(annotatedAnnotation); } }
@Override protected void initValid(EnhancedAnnotation<T> annotatedAnnotation) { super.initValid(annotatedAnnotation); for (EnhancedAnnotatedMethod<?, ?> annotatedMethod : annotatedAnnotation.getMembers()) { if ((Reflections.isArrayType(annotatedMethod.getJavaClass()) || Annotation.class.isAssignableFrom(annotatedMethod.getJavaClass())) && !getNonBindingMembers().contains(annotatedMethod.slim())) { MetadataLogger.LOG.nonBindingMemberType(annotatedMethod); super.valid = false; } } }
@Override protected void check(EnhancedAnnotation<T> annotatedAnnotation) { super.check(annotatedAnnotation); if (isValid()) { if (!annotatedAnnotation.isAnnotationPresent(Target.class)) { ReflectionLogger.LOG.missingTarget(annotatedAnnotation); } else if (!Arrays2.unorderedEquals(annotatedAnnotation.getAnnotation(Target.class).value(), METHOD, FIELD, TYPE)) { ReflectionLogger.LOG.missingTargetMethodFieldType(annotatedAnnotation); } } }
protected void check(EnhancedAnnotation<T> annotatedAnnotation) { super.check(annotatedAnnotation); if (isValid()) { if (!annotatedAnnotation.isAnnotationPresent(Target.class)) { ReflectionLogger.LOG.missingTarget(annotatedAnnotation); } if (!isValidTargetType(annotatedAnnotation)) { ReflectionLogger.LOG.missingTargetTypeMethodOrTargetType(annotatedAnnotation); } } }
/** * Validates the members */ protected void check(EnhancedAnnotation<T> annotatedAnnotation) { super.check(annotatedAnnotation); if (isValid()) { if (!annotatedAnnotation.isAnnotationPresent(Target.class)) { ReflectionLogger.LOG.missingTarget(annotatedAnnotation); } else if (!Arrays2.unorderedEquals(annotatedAnnotation.getAnnotation(Target.class).value(), METHOD, FIELD, PARAMETER, TYPE)) { ReflectionLogger.LOG.missingTargetMethodFieldParameterType(annotatedAnnotation); } } }
@Override protected void init(EnhancedAnnotation<T> annotatedAnnotation) { super.init(annotatedAnnotation); if (isValid()) { initInterceptionBindingTypes(annotatedAnnotation); checkArrayAndAnnotationValuedMembers(annotatedAnnotation); checkMetaAnnotations(annotatedAnnotation); this.metaAnnotations = annotatedAnnotation.getAnnotations(); } }
@Override protected void check(EnhancedAnnotation<T> annotatedAnnotation) { super.check(annotatedAnnotation); if (isValid()) { if (!annotatedAnnotation.isAnnotationPresent(Target.class)) { ReflectionLogger.LOG.missingTarget(annotatedAnnotation); } else { ElementType[] elementTypes = annotatedAnnotation.getAnnotation(Target.class).value(); if (!(Arrays2.unorderedEquals(elementTypes, METHOD, FIELD, TYPE) || Arrays2.unorderedEquals(elementTypes, TYPE) || Arrays2.unorderedEquals(elementTypes, METHOD) || Arrays2.unorderedEquals(elementTypes, FIELD) || Arrays2.unorderedEquals(elementTypes, METHOD, TYPE) )) { ReflectionLogger.LOG.missingTargetMethodFieldTypeParameterOrTargetMethodTypeOrTargetMethodOrTargetTypeOrTargetField(annotatedAnnotation); } } } }
protected void initNonBindingMembers(EnhancedAnnotation<T> annotatedAnnotation) { Set<EnhancedAnnotatedMethod<?, ?>> enhancedMethods = annotatedAnnotation.getMembers(Nonbinding.class); if (enhancedMethods.isEmpty()) { this.nonBindingMembers = Collections.emptySet(); } else { Set<AnnotatedMethod<?>> nonBindingMembers = new HashSet<AnnotatedMethod<?>>(); for (EnhancedAnnotatedMethod<?, ?> method : enhancedMethods) { nonBindingMembers.add(method.slim()); } this.nonBindingMembers = immutableSetView(nonBindingMembers); } }
/** * Initializes the default scope type */ private void initDefaultScopeType(EnhancedAnnotation<T> annotatedAnnotation) { Set<Annotation> scopeTypes = new HashSet<Annotation>(); scopeTypes.addAll(annotatedAnnotation.getMetaAnnotations(Scope.class)); scopeTypes.addAll(annotatedAnnotation.getMetaAnnotations(NormalScope.class)); if (scopeTypes.size() > 1) { throw MetadataLogger.LOG.multipleScopes(annotatedAnnotation); } else if (scopeTypes.size() == 1) { this.defaultScopeType = scopeTypes.iterator().next(); } }
private static boolean isValidTargetType(EnhancedAnnotation<?> annotation) { Target target = annotation.getAnnotation(Target.class); return target != null && (Arrays2.unorderedEquals(target.value(), ElementType.TYPE, ElementType.METHOD) || Arrays2.unorderedEquals(target.value(), ElementType.TYPE)); }
/** * Initializes the interceptor bindings */ private void initInterceptorBindings(EnhancedAnnotation<T> annotatedAnnotation) { interceptorBindings = annotatedAnnotation.getMetaAnnotations(InterceptorBinding.class); }
/** * Constructor * * @param type The annotation type */ public AnnotationModel(EnhancedAnnotation<T> enhancedAnnotatedAnnotation) { this.annotatedAnnotation = enhancedAnnotatedAnnotation.slim(); init(enhancedAnnotatedAnnotation); }
@Override protected void init(EnhancedAnnotation<T> annotatedAnnotation) { super.init(annotatedAnnotation); if (valid) { initAlternative(annotatedAnnotation); initDefaultScopeType(annotatedAnnotation); initBeanNameDefaulted(annotatedAnnotation); initInterceptorBindings(annotatedAnnotation); initInheritedStereotypes(annotatedAnnotation); checkBindings(annotatedAnnotation); this.metaAnnotations = annotatedAnnotation.getAnnotations(); } }
public Set<EnhancedAnnotatedMethod<?, ?>> getMembers() { return delegate().getMembers(); }
@Override protected void initValid(EnhancedAnnotation<T> annotatedAnnotation) { super.initValid(annotatedAnnotation); for (EnhancedAnnotatedMethod<?, ?> annotatedMethod : annotatedAnnotation.getMembers()) { if ((Reflections.isArrayType(annotatedMethod.getJavaClass()) || Annotation.class.isAssignableFrom(annotatedMethod.getJavaClass())) && !getNonBindingMembers().contains(annotatedMethod.slim())) { MetadataLogger.LOG.nonBindingMemberType(annotatedMethod); super.valid = false; } } }
@Override protected void check(EnhancedAnnotation<T> annotatedAnnotation) { super.check(annotatedAnnotation); if (isValid()) { if (!annotatedAnnotation.isAnnotationPresent(Target.class)) { ReflectionLogger.LOG.missingTarget(annotatedAnnotation); } else if (!Arrays2.unorderedEquals(annotatedAnnotation.getAnnotation(Target.class).value(), METHOD, FIELD, TYPE)) { ReflectionLogger.LOG.missingTargetMethodFieldType(annotatedAnnotation); } } }