// for each annotations defined on the declaration, if the annotation
// is a PropertySet, ensure the values assigned to the properties
// satisfy all PropertySet and PropertyType constraints.
for (AnnotationMirror m : mirrors)
{
AnnotationTypeDeclaration decl = m.getAnnotationType().getDeclaration();
/*
when embedding this annotation processor in an IDE, the declaration
could be null when it doesn't resolve to a valid type. In this case,
just continue processing declarations.
*/
if(decl == null) {
continue;
}
else if (decl.getAnnotation(PropertySet.class) != null)
{
Iterator<Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue>> i =
m.getElementValues().entrySet().iterator();
while (i.hasNext())
{
Map.Entry<AnnotationTypeElementDeclaration, AnnotationValue> entry =
i.next();
Collection<Annotation> annotations = getMemberTypeAnnotations(entry.getKey());
if (annotations.size() > 0)
{
Annotation[] anArray = new Annotation[annotations.size()];
annotations.toArray(anArray);
validate(anArray, entry.getValue().getValue());
}
}
//If a membership rule is defined on the property set, ensure the rule is satisfied.
if (decl.getAnnotation(MembershipRule.class) != null)
{
try
{
String declClassName = decl.getQualifiedName();
TypeDeclaration owningClass = decl.getDeclaringType();
if (owningClass != null)
declClassName = owningClass.getQualifiedName() + "$" + decl.getSimpleName();
Class clazz = Class.forName(declClassName);
Annotation a = d.getAnnotation(clazz);
validateMembership(a);
}