final MethodMetadata toTypeConverterMethod = getGovernorMethod(methodName);
if (findMethod == null) {
return null;
}
if (toTypeConverterMethod != null) {
return new MethodMetadataBuilder(toTypeConverterMethod);
}
findMethod.copyAdditionsTo(builder, governorTypeDetails);
final JavaType converterJavaType = SpringJavaType.getConverterType(
idType, targetType);
final InvocableMemberBodyBuilder bodyBuilder = new InvocableMemberBodyBuilder();
bodyBuilder.appendFormalLine("return new "
+ converterJavaType.getNameIncludingTypeParameters() + "() {");
bodyBuilder.indent();
bodyBuilder.appendFormalLine("public "
+ targetType.getFullyQualifiedTypeName() + " convert(" + idType
+ " id) {");
bodyBuilder.indent();
bodyBuilder.appendFormalLine("return " + findMethod.getMethodCall()
+ ";");
bodyBuilder.indentRemove();
bodyBuilder.appendFormalLine("}");
bodyBuilder.indentRemove();
bodyBuilder.appendFormalLine("};");
return new MethodMetadataBuilder(getId(), Modifier.PUBLIC, methodName,
converterJavaType, bodyBuilder);
}