private final Map<String, String> pluralMap = new HashMap<String, String>();
private final Map<String, Matcher<? extends CustomDataAccessor>> taggerMap = new HashMap<String, Matcher<? extends CustomDataAccessor>>();
public MemberDetails decorate(final String requestingClass,
final MemberDetails memberDetails) {
final MemberDetailsBuilder memberDetailsBuilder = new MemberDetailsBuilder(
memberDetails);
for (final MemberHoldingTypeDetails memberHoldingTypeDetails : memberDetails
.getDetails()) {
if (memberHoldingTypeDetails instanceof ClassOrInterfaceTypeDetails) {
if (!pluralMap.containsKey(memberHoldingTypeDetails
.getDeclaredByMetadataId())) {
pluralMap.put(
memberHoldingTypeDetails.getDeclaredByMetadataId(),
getInflectorPlural(memberHoldingTypeDetails
.getName().getSimpleTypeName(),
Locale.ENGLISH));
}
}
}
// Locate any requests that we add custom data to identifiable java
// structures
for (final FieldMatcher fieldTagger : getFieldTaggers()) {
for (final FieldMetadata field : fieldTagger.matches(memberDetails
.getDetails())) {
memberDetailsBuilder.tag(field, fieldTagger.getCustomDataKey(),
fieldTagger.getTagValue(field));
}
}
for (final MethodMatcher methodTagger : getMethodTaggers()) {
for (final MethodMetadata method : methodTagger.matches(
memberDetails.getDetails(), pluralMap)) {
memberDetailsBuilder.tag(method,
methodTagger.getCustomDataKey(),
methodTagger.getTagValue(method));
}
}
for (final ConstructorMatcher constructorTagger : getConstructorTaggers()) {
for (final ConstructorMetadata constructor : constructorTagger
.matches(memberDetails.getDetails())) {
memberDetailsBuilder.tag(constructor,
constructorTagger.getCustomDataKey(),
constructorTagger.getTagValue(constructor));
}
}
for (final TypeMatcher typeTagger : getTypeTaggers()) {
for (final MemberHoldingTypeDetails typeDetails : typeTagger
.matches(memberDetails.getDetails())) {
memberDetailsBuilder.tag(typeDetails,
typeTagger.getCustomDataKey(),
typeTagger.getTagValue(typeDetails));
}
}
return memberDetailsBuilder.build();
}