{
if ( decl instanceof FieldDeclaration )
{
FieldDeclaration fd = (FieldDeclaration)decl;
TypeDeclaration clientType = fd.getDeclaringType();
TypeMirror controlFieldType = fd.getType();
addControlType( clientsMap, clientType, controlFieldType );
/*
Add the control type to any derived class. Fields with
private and default (package) access are also included
here as the controls in superclasses may be exposed
through public or protected methods to subclasses.
*/
Collection<TypeDeclaration> specifiedTypeDeclartions = env.getSpecifiedTypeDeclarations();
for (TypeDeclaration td : specifiedTypeDeclartions)
{
if (td instanceof ClassDeclaration)
{
ClassType superclass = ((ClassDeclaration) td).getSuperclass();
while (superclass != null)
{
if (superclass.getDeclaration().equals(clientType))
{
addControlType(clientsMap, td, controlFieldType);
break;
}
superclass = superclass.getSuperclass();
}
}
}
}
}
}
else if (atd.getSimpleName().equals("ControlReferences"))
{
Collection<Declaration> decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith(atd);
for (Declaration decl : decls)
{
if ( decl instanceof TypeDeclaration )
{
TypeDeclaration clientType = (TypeDeclaration)decl;
Set<TypeMirror> controlTypes = clientsMap.get( clientType );
if ( controlTypes == null )
{
controlTypes = new HashSet<TypeMirror>();
clientsMap.put( clientType, controlTypes );
}
// Read ControlReferences annotation
AnnotationMirror controlMirror = null;
for (AnnotationMirror annot : clientType.getAnnotationMirrors())
{
if (annot.getAnnotationType().getDeclaration().getQualifiedName().equals(
"org.apache.beehive.controls.api.bean.ControlReferences"))
{
controlMirror = annot;
break;
}
}
assert( controlMirror != null );
// Add each control type listed in the ControlReferences annotation
AptAnnotationHelper controlAnnot = new AptAnnotationHelper(controlMirror);
Collection<AnnotationValue> references = (Collection<AnnotationValue>)controlAnnot.getObjectValue("value");
if ( references != null )
{
for ( AnnotationValue av : references )
{
TypeMirror crType = (TypeMirror)av.getValue();
controlTypes.add( crType );
}
}
}
}