Here you can find the source of getGetterSetterMethodsParameterType(Field f)
public static Class getGetterSetterMethodsParameterType(Field f)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; import java.lang.reflect.Method; public class Main { public static Class getGetterSetterMethodsParameterType(Field f) { Method getter = prepareGetterMethod(f); if (getter == null) { return null; }/* w w w .j ava 2 s .c o m*/ Class rt = getter.getReturnType(); Method setter = prepareSetterMethod(f, rt); return (setter == null) ? null : rt; } public static Method prepareGetterMethod(Field f) { String t = prepareAccessorMainPartName(f.getName()); @SuppressWarnings("unused") String sm; String gm; if (f.getType().isPrimitive() && f.getType().equals(boolean.class)) { sm = "set" + t; gm = "is" + t; } else { sm = "set" + t; gm = "get" + t; } try { Method m = f.getDeclaringClass().getMethod(gm); return m; } catch (NoSuchMethodException e) { return null; } } public static Method prepareSetterMethod(Field f) { return prepareSetterMethod(f, f.getType()); } public static Method prepareSetterMethod(Field f, Class type) { String t = prepareAccessorMainPartName(f.getName()); String sm; @SuppressWarnings("unused") String gm; if (f.getType().isPrimitive() && f.getType().equals(boolean.class)) { sm = "set" + t; gm = "is" + t; } else { sm = "set" + t; gm = "get" + t; } try { Method m = f.getDeclaringClass().getMethod(sm, type); return m; } catch (NoSuchMethodException e) { return null; // throw new KernelException("Class " + // f.getDeclaringClass().getName() + " has no setter of field " + // f.getName(), e); } } public static String prepareAccessorMainPartName(final String fieldName) { if (fieldName.length() == 1) { return fieldName.toUpperCase(); } String r; if (Character.isUpperCase(fieldName.charAt(1))) { r = fieldName.substring(0, 1); } else { r = fieldName.substring(0, 1).toUpperCase(); } r += fieldName.substring(1); return r; } }