final CtMethod reader = CtNewMethod.getter( readerName, persistentField );
managedCtClass.addMethod( reader );
return reader;
}
catch (CannotCompileException e) {
throw new EnhancementException(
String.format(
"Could not enhance entity class [%s] to add field reader method [%s]",
managedCtClass.getName(),
readerName
),
e
);
}
}
// temporary solution...
final String methodBody = typeDescriptor.buildReadInterceptionBodyFragment( fieldName )
+ " return this." + fieldName + ";";
try {
final CtMethod reader = CtNewMethod.make(
Modifier.PRIVATE,
persistentField.getType(),
readerName,
null,
null,
"{" + methodBody + "}",
managedCtClass
);
managedCtClass.addMethod( reader );
return reader;
}
catch (Exception e) {
throw new EnhancementException(
String.format(
"Could not enhance entity class [%s] to add field reader method [%s]",
managedCtClass.getName(),
readerName
),