Here you can find the source of getGetter(final Class> clazz, final String fieldName)
public static Method getGetter(final Class<?> clazz, final String fieldName)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; public class Main { public static Method getGetter(final Class<?> clazz, final String fieldName) { final String methodName = "get" + capitalize(fieldName); // public method try {/* www. j a v a 2 s .c om*/ final Method method = clazz.getMethod(methodName, Void.class); return method; } catch (SecurityException | NoSuchMethodException e) { } // private / protected method try { final Method method = clazz.getDeclaredMethod(methodName, Void.class); method.setAccessible(true); return method; } catch (SecurityException | NoSuchMethodException e) { } return null; } public static String capitalize(final String str) { final int strLen; if (str == null || (strLen = str.length()) == 0) { return str; } return new StringBuilder(strLen).append(String.valueOf(str.charAt(0)).toUpperCase()) .append(str.substring(1)).toString(); } }