* related metadata class.
* 3- For each round we must update all metadata classes for each round
* element.
*/
public MetadataClass getMetadataClass(Element element) {
MetadataClass metadataClass = roundElements.get(element);
if (metadataClass == null) {
// Only log if logging on finest.
boolean shouldLog = getLogger().getSession().getLogLevel() == SessionLog.FINEST;
// As a performance gain, avoid visiting this class if it is not a
// round element. We must re-visit round elements.
if (isRoundElement(element)) {
if (shouldLog) {
processingEnv.getMessager().printMessage(Kind.NOTE, "Building metadata class for round element: " + element);
}
metadataClass = new MetadataClass(MetadataMirrorFactory.this, "");
roundElements.put(element, metadataClass);
roundMetadataClasses.add(metadataClass);
// Kick off the visiting of elements.
element.accept(elementVisitor, metadataClass);
// The name of the metadata class is a qualified name from a
// type element. Set this name on the MetadataFactory map. We
// can't call addMetadataClass till we have visited the class.
addMetadataClass(metadataClass);
} else {
String name = element.toString();
if (metadataClassExists(name)) {
return getMetadataClass(name);
}
// So we are not a round element, the outcome is as follows:
// - TypeElement or TypeParameterElement in existing class map,
// return it.
// - TypeElement, and not in the existing class map, return
// simple non-visited MetadataClass with only a name/type.
// - TypeParameterElement, and not in the existing class map,
// visit it to ensure we get the correct generic type set
// and return it.
// - Everything else, return simple non-visited MetadataClass
// with only a name/type from the toString value.
if (element instanceof TypeElement || element instanceof TypeParameterElement) {
if (element instanceof TypeElement) {
if (shouldLog) {
processingEnv.getMessager().printMessage(Kind.NOTE, "Building metadata class for type element: " + name);
}
metadataClass = new MetadataClass(MetadataMirrorFactory.this, name);
addMetadataClass(metadataClass);
element.accept(elementVisitor, metadataClass);
addMetadataClass(metadataClass);
} else {
// Only thing going to get through at this point are
// TypeParameterElements (presumably generic ones). Look
// at those further since they 'should' be simple visits.
if (shouldLog) {
processingEnv.getMessager().printMessage(Kind.NOTE, "Building type parameter element: " + name);
}
metadataClass = new MetadataClass(MetadataMirrorFactory.this, name);
addMetadataClass(metadataClass);
element.accept(elementVisitor, metadataClass);
addMetadataClass(metadataClass);
}
} else {