/** * Create a new Annotation value * * @param annotationType the annotation info * @param attributeValues the attribute values * @param underlying the underlying annotation */ public AnnotationValueImpl(AnnotationInfo annotationType, HashMap<String, Value> attributeValues, Annotation underlying) { if (annotationType == null) throw new IllegalArgumentException("Null annotationType"); if (attributeValues == null) throw new IllegalArgumentException("Null attribute values"); this.annotationType = annotationType; this.attributeValues = attributeValues; this.underlying = underlying; calculateHash(); }
public static AnnotationValue createAnnotationValue(TypeInfoFactory typeInfoFactory, AnnotationHelper annotationHelper, AnnotationInfo info, Object ann) { Annotation annotation = (Annotation)ann; Class clazz = annotation.annotationType(); ClassInfo clazzInfo = (ClassInfo) typeInfoFactory.getTypeInfo(clazz); HashMap<String, Value> attributes = new HashMap<String, Value>(); MethodInfo[] methods = clazzInfo.getDeclaredMethods(); if (methods != null) { for (int j = 0 ; j < methods.length ; j++) { try { Object val = methods[j].invoke(annotation, null); TypeInfo typeInfo = methods[j].getReturnType(); Value value = createValue(annotationHelper, typeInfo, val); attributes.put(methods[j].getName(), value); } catch (Throwable e) { throw new RuntimeException("Error retrieving annotation attribute values", e); } } } return new AnnotationValueImpl(info, attributes, annotation); }
return new AnnotationValueImpl(info, attributes, annotation);
/** * Create a new Annotation value * * @param annotationType the annotation info * @param attributeValues the attribute values * @param underlying the underlying annotation */ public AnnotationValueImpl(AnnotationInfo annotationType, HashMap<String, Value> attributeValues, Annotation underlying) { if (annotationType == null) throw new IllegalArgumentException("Null annotationType"); if (attributeValues == null) throw new IllegalArgumentException("Null attribute values"); this.annotationType = annotationType; this.attributeValues = attributeValues; this.underlying = underlying; calculateHash(); }