@SuppressWarnings({ "rawtypes", "unchecked" })
private static String getMethodName( final TypeElement classElement,
final ProcessingEnvironment processingEnvironment,
final String expectedReturnType,
final Class annotation ) throws GenerationException {
final Types typeUtils = processingEnvironment.getTypeUtils();
final Elements elementUtils = processingEnvironment.getElementUtils();
final TypeMirror requiredReturnType = elementUtils.getTypeElement( expectedReturnType ).asType();
final List<ExecutableElement> methods = ElementFilter.methodsIn( classElement.getEnclosedElements() );
ExecutableElement match = null;
for ( ExecutableElement e : methods ) {
final TypeMirror actualReturnType = e.getReturnType();
//Check method
if ( e.getAnnotation( annotation ) == null ) {
continue;
}
if ( !typeUtils.isAssignable( actualReturnType,
requiredReturnType ) ) {
continue;
}
if ( e.getParameters().size() != 0 ) {
continue;