// process TypeDeclaration (class, interface)
if (abstractTypeDeclaration instanceof TypeDeclaration) {
TypeDeclaration typeDeclaration = (TypeDeclaration)abstractTypeDeclaration;
if (typeDeclaration.isInterface()) {
// is an interface top level type
TypeMetadata interfaceMetadata = TypeMetadata.interfaceType(JavaMetadataUtil.getName(typeDeclaration.getName()));
// detect the interfaces, if any
for (Type superInterfaceType : (List<Type>)typeDeclaration.superInterfaceTypes()) {
interfaceMetadata.getInterfaceNames().add(getTypeName(superInterfaceType));
}
metadata.add(interfaceMetadata);
} else {
// is a class top level type
TypeMetadata classMetadata = TypeMetadata.classType(JavaMetadataUtil.getName(typeDeclaration.getName()));
processModifiersOfTypeDeclaration(typeDeclaration, classMetadata);
// set the superclass, if any
Type superClassType = typeDeclaration.getSuperclassType();
if (superClassType != null) {
classMetadata.setSuperTypeName(getTypeName(superClassType));
}
// detect the interfaces, if any
for (Type superInterfaceType : (List<Type>)typeDeclaration.superInterfaceTypes()) {
classMetadata.getInterfaceNames().add(getTypeName(superInterfaceType));
}
// fields of the class top level type
FieldDeclaration[] fieldDeclarations = typeDeclaration.getFields();
for (FieldDeclaration fieldDeclaration : fieldDeclarations) {
FieldMetadata fieldMetadata = getFieldMetadataFrom(fieldDeclaration);
classMetadata.getFields().add(fieldMetadata);
}
// methods of the class top level type
MethodDeclaration[] methodDeclarations = typeDeclaration.getMethods();
for (MethodDeclaration methodDeclaration : methodDeclarations) {
MethodMetadata methodMetadata = getMethodMetadataFrom(methodDeclaration);
classMetadata.getMethods().add(methodMetadata);
}
metadata.add(classMetadata);
}
}