// Flag to indicate whether we'll even try to create this metadata
boolean produceMetadata = false;
// Determine if we should generate the metadata on the basis of it
// containing a trigger annotation
final ClassOrInterfaceTypeDetails cid = governorPhysicalTypeMetadata
.getMemberHoldingTypeDetails();
if (cid != null) {
// Only create metadata if the type is annotated with one of the
// metadata triggers
for (final JavaType trigger : metadataTriggers) {
if (cid.getAnnotation(trigger) != null) {
produceMetadata = true;
break;
}
}
}
// Fall back to ignoring trigger annotations
if (ignoreTriggerAnnotations) {
produceMetadata = true;
}
// Cancel production if the governor type details are required, but
// aren't available
if (dependsOnGovernorTypeDetailAvailability && cid == null) {
produceMetadata = false;
}
// Cancel production if the governor is not a class, and the subclass
// only wants to know about classes
if (cid != null && dependsOnGovernorBeingAClass
&& cid.getPhysicalTypeCategory() != PhysicalTypeCategory.CLASS) {
produceMetadata = false;
}
final String itdFilename = governorPhysicalTypeMetadata
.getItdCanonicalPath(this);
if (!produceMetadata && isGovernor(cid)
&& fileManager.exists(itdFilename)) {
// We don't seem to want metadata anymore, yet the ITD physically
// exists, so get rid of it
// This might be because the trigger annotation has been removed,
// the governor is missing a class declaration, etc.
deleteItd(metadataIdentificationString, itdFilename,
"not required for governor " + cid.getName(), true);
return null;
}
if (produceMetadata) {
// This type contains an annotation we were configured to detect, or