private static EnhancedAnnotatedType<?> createAnnotatedTypeForExistingBeanClass(String bdaId, Bean<?> bean) { ClassTransformer classTransformer = getClassTransformer(); SlimAnnotatedType<?> annotatedType = classTransformer.getBackedAnnotatedType(bean.getBeanClass(), bdaId); return EnhancedAnnotatedTypeImpl.of(annotatedType, classTransformer); }
this.superclass = classTransformer.getEnhancedAnnotatedType(Object.class, AnnotatedTypeIdentifier.NULL_BDA_ID); ArrayList<EnhancedAnnotatedField<?, ? super T>> declaredFieldsTemp = new ArrayList<EnhancedAnnotatedField<?, ? super T>>(); Class<T> javaClass = annotatedType.getJavaClass(); declaredFieldsTemp.add(annotatedField); for (Annotation annotation : annotatedField.getAnnotations()) { declaredAnnotatedFields.put(annotation.annotationType(), annotatedField); if ((superclass != null) && (superclass.getJavaClass() != Object.class)) { fieldsTemp = Sets.union(fieldsTemp, Reflections.<Set<EnhancedAnnotatedField<?, ? super T>>>cast(superclass.getFields())); if (weldMethod.getEnhancedParameters(annotationType).size() > 0) { this.declaredMethodsByAnnotatedParameters = Multimaps.unmodifiableMultimap(declaredMethodsByAnnotatedParameters); SetMultimap<Class<? extends Annotation>, Annotation> declaredMetaAnnotationMap = SetMultimap.newSetMultimap(); processMetaAnnotations(declaredMetaAnnotationMap, declaredAnnotationMap.values(), classTransformer, true); this.declaredMetaAnnotationMap = Multimaps.unmodifiableMultimap(declaredMetaAnnotationMap); this.overriddenMethods = getOverriddenMethods(this, methodsTemp); methodsTemp.removeAll(getOverriddenMethods(this, methodsTemp, true)); this.annotatedMethods = buildAnnotatedMethodMultimap(this.methods); this.annotatedMethodsByAnnotatedParameters = buildAnnotatedParameterMethodMultimap(this.methods);
this.superclass = classTransformer.getEnhancedAnnotatedType(Object.class, AnnotatedTypeIdentifier.NULL_BDA_ID); ArrayList<EnhancedAnnotatedField<?, ? super T>> declaredFieldsTemp = new ArrayList<EnhancedAnnotatedField<?, ? super T>>(); Class<T> javaClass = annotatedType.getJavaClass(); if ((superclass != null) && (superclass.getJavaClass() != Object.class)) { fieldsTemp = Sets.union(fieldsTemp, Reflections.<Set<EnhancedAnnotatedField<?, ? super T>>>cast(superclass.getFields())); if (weldMethod.getEnhancedParameters(annotationType).size() > 0) { this.declaredMethodsByAnnotatedParameters = Multimaps.unmodifiableMultimap(declaredMethodsByAnnotatedParameters); addMetaAnnotations(declaredMetaAnnotationMap, declaredAnnotation, classTransformer.getReflectionCache() .getAnnotations(declaredAnnotation.annotationType()), true); } else { addMetaAnnotations(declaredMetaAnnotationMap, declaredAnnotation, addMetaAnnotations(declaredMetaAnnotationMap, declaredAnnotation, classTransformer.getTypeStore().get(declaredAnnotation.annotationType()), true); declaredMetaAnnotationMap.put(declaredAnnotation.annotationType(), declaredAnnotation); this.overriddenMethods = getOverriddenMethods(this, methodsTemp); methodsTemp.removeAll(getOverriddenMethods(this, methodsTemp, true)); this.annotatedMethods = buildAnnotatedMethodMultimap(this.methods); this.annotatedMethodsByAnnotatedParameters = buildAnnotatedParameterMethodMultimap(this.methods);
public static <T> EnhancedAnnotatedType<T> of(SlimAnnotatedType<T> annotatedType, ClassTransformer classTransformer) { if (annotatedType instanceof BackedAnnotatedType<?>) { return new EnhancedAnnotatedTypeImpl<T>(annotatedType, buildAnnotationMap(annotatedType.getAnnotations()), buildAnnotationMap(classTransformer.getReflectionCache().getDeclaredAnnotations(annotatedType.getJavaClass())), classTransformer); } else { return new EnhancedAnnotatedTypeImpl<T>(annotatedType, buildAnnotationMap(annotatedType.getAnnotations()), buildAnnotationMap(annotatedType.getAnnotations()), classTransformer); } }
@Override public <M> EnhancedAnnotatedMethod<M, ?> getEnhancedMethod(MethodSignature signature) { EnhancedAnnotatedMethod<M, ?> method = cast(getDeclaredEnhancedMethod(signature)); if ((method == null) && (superclass != null) && (superclass.getJavaClass() != Object.class)) { method = superclass.getEnhancedMethod(signature); } return method; }
@Override public <M> EnhancedAnnotatedMethod<M, ?> getDeclaredEnhancedMethod(MethodSignature signature) { for (EnhancedAnnotatedMethod<?, ? super T> method : declaredMethods) { if (method.getSignature().equals(signature)) { return cast(method); } } return null; }
/** * Indicates if the type if final * * @return True if final, false otherwise * @see org.jboss.weld.annotated.enhanced.EnhancedAnnotated#isFinal() */ @Override public boolean isFinal() { return Reflections.isFinal(getDelegate()); }
/** * Indicates if the type is static * * @return True if static, false otherwise * @see org.jboss.weld.annotated.enhanced.EnhancedAnnotated#isStatic() */ @Override public boolean isStatic() { return Reflections.isStatic(getDelegate()); }
@Override public boolean isSerializable() { return Reflections.isSerializable(getJavaClass()); }
@Override public boolean isPackagePrivate() { return Reflections.isPackagePrivate(getJavaClass().getModifiers()); }
/** * Gets the delegate (class) * * @return The class */ @Override public Class<T> getDelegate() { return getJavaClass(); }
@Override public EnhancedAnnotatedType<?> apply(SlimAnnotatedType<?> annotatedType) { return EnhancedAnnotatedTypeImpl.of(annotatedType, ClassTransformer.this); } }
@Override public <U> EnhancedAnnotatedType<? extends U> asEnhancedSubclass(EnhancedAnnotatedType<U> clazz) { return cast(this); }
@Override public boolean isEquivalent(Class<?> clazz) { return getDelegate().equals(clazz); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (getClass() != obj.getClass()) { return false; } EnhancedAnnotationImpl<?> that = cast(obj); return super.equals(that); } }
this.superclass = classTransformer.getEnhancedAnnotatedType(Object.class, AnnotatedTypeIdentifier.NULL_BDA_ID); ArrayList<EnhancedAnnotatedField<?, ? super T>> declaredFieldsTemp = new ArrayList<EnhancedAnnotatedField<?, ? super T>>(); Class<T> javaClass = annotatedType.getJavaClass(); declaredFieldsTemp.add(annotatedField); for (Annotation annotation : annotatedField.getAnnotations()) { declaredAnnotatedFields.put(annotation.annotationType(), annotatedField); if ((superclass != null) && (superclass.getJavaClass() != Object.class)) { fieldsTemp = Sets.union(fieldsTemp, Reflections.<Set<EnhancedAnnotatedField<?, ? super T>>>cast(superclass.getFields())); if (weldMethod.getEnhancedParameters(annotationType).size() > 0) { this.declaredMethodsByAnnotatedParameters = Multimaps.unmodifiableMultimap(declaredMethodsByAnnotatedParameters); SetMultimap<Class<? extends Annotation>, Annotation> declaredMetaAnnotationMap = SetMultimap.newSetMultimap(); processMetaAnnotations(declaredMetaAnnotationMap, declaredAnnotationMap.values(), classTransformer, true); this.declaredMetaAnnotationMap = Multimaps.unmodifiableMultimap(declaredMetaAnnotationMap); this.overriddenMethods = getOverriddenMethods(this, methodsTemp); methodsTemp.removeAll(getOverriddenMethods(this, methodsTemp, true)); this.annotatedMethods = buildAnnotatedMethodMultimap(this.methods); this.annotatedMethodsByAnnotatedParameters = buildAnnotatedParameterMethodMultimap(this.methods);
public static <T> EnhancedAnnotatedType<T> of(SlimAnnotatedType<T> annotatedType, ClassTransformer classTransformer) { if (annotatedType instanceof BackedAnnotatedType<?>) { return new EnhancedAnnotatedTypeImpl<T>(annotatedType, buildAnnotationMap(annotatedType.getAnnotations()), buildAnnotationMap(classTransformer.getReflectionCache().getDeclaredAnnotations(annotatedType.getJavaClass())), classTransformer); } else { return new EnhancedAnnotatedTypeImpl<T>(annotatedType, buildAnnotationMap(annotatedType.getAnnotations()), buildAnnotationMap(annotatedType.getAnnotations()), classTransformer); } }
@Override public <M> EnhancedAnnotatedMethod<M, ?> getEnhancedMethod(MethodSignature signature) { EnhancedAnnotatedMethod<M, ?> method = cast(getDeclaredEnhancedMethod(signature)); if ((method == null) && (superclass != null) && (superclass.getJavaClass() != Object.class)) { method = superclass.getEnhancedMethod(signature); } return method; }