public static MethodDeclaration findGetterForField( @NotNull ClassDeclaration classDeclaration, @NotNull @NonNls String simpleName, @NotNull TypeMirror type ) {
String expectedName = "get" + simpleName.substring( 0, 1 ).toUpperCase() + simpleName.substring( 1 );
for ( MethodDeclaration methodDeclaration : classDeclaration.getMethods() ) {
if ( methodDeclaration.getSimpleName().equals( expectedName ) ) {
TypeMirror returnType = methodDeclaration.getReturnType();
if ( isAssignable( type, returnType ) ) {
return methodDeclaration;
} else {
throw new IllegalArgumentException( "Invalid return types for <" + expectedName + ">. Was <" + returnType + "> but expected <" + type + ">" );
}