Java Utililty Methods Reflection Method Getter Get

List of utility methods to do Reflection Method Getter Get

Description

The list of methods to do Reflection Method Getter Get are organized into topic(s).

Method

MethodgetGetterMethod(Class clazz, String fieldName)
get Getter Method
String methodName = "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
try {
    return getInheritMethod(clazz, methodName, new Class<?>[] {});
} catch (NoSuchMethodException e) {
    throw new RuntimeException(e);
MethodgetGetterMethod(Class clazz, String methodNameWithoutGetPrefix)
get Getter Method
Method getterMethod = null;
Method[] methods = clazz.getDeclaredMethods();
if (isNotEmpty(methods)) {
    for (Method method : methods) {
        if (method.getName().equals("get" + methodNameWithoutGetPrefix)
                && method.getGenericParameterTypes().length == 0) {
            getterMethod = method;
            break;
...
MethodgetGetterMethod(Class clazz, String name)
get Getter Method
String methodName = convertToMehtodName("get", name);
Method method = null;
try {
    method = clazz.getMethod(methodName);
} catch (Exception e) {
    throw new RuntimeException("get method exception - ", e);
return method;
...
MethodgetGetterMethod(Class clazz, String propertyName)
get Getter Method
final String camelCase = propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1);
String getterName = "get" + camelCase;
Method getterMethod;
try {
    getterMethod = clazz.getMethod(getterName);
} catch (Exception e) {
    getterName = "is" + camelCase;
    try {
...
MethodgetGetterMethod(String getterName, Object bean, Class returnType)
get Getter Method
return getGetterMethod(getterName, bean.getClass(), returnType);
MethodgetGetterMethodByProperty(String propertyName, Class beanClass, Class returnType)
get Getter Method By Property
Method getter = getGetterMethod(toGetterName(propertyName), beanClass, returnType);
if (getter == null) {
    getter = getGetterMethod(toIsGetterName(propertyName), beanClass, returnType);
return getter;
MethodgetGetterMethodForClass(Class cls, String beanName)
Obtain a (Java bean) getter method from a class or superclasses using reflection.
Method getter = findDeclaredMethodInHeirarchy(cls, getJavaBeanGetterName(beanName, false));
if (getter == null) {
    getter = findDeclaredMethodInHeirarchy(cls, getJavaBeanGetterName(beanName, true));
return getter;
StringgetGetterMethodName(String fieldName, java.lang.Class fieldType)
Get the getter method names for attributes.
String firstStringChar = fieldName.substring(0, 1).toUpperCase();
String remaingString = fieldName.substring(1);
String methodName = null;
if (fieldType != null && fieldType == boolean.class || fieldType == Boolean.class) {
    methodName = "is" + firstStringChar + remaingString;
} else {
    methodName = "get" + firstStringChar + remaingString;
return methodName;
StringgetGetterMethodName(String property, String javaType)
get Getter Method Name
StringBuilder sb = new StringBuilder();
sb.append(property);
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
if (javaType.equals("boolean") || javaType.equals("Boolean") || javaType.equals("java.lang.Boolean")) {
    sb.insert(0, "is");
} else {
    sb.insert(0, "get");
return sb.toString();
ListgetGetterMethodNames(Object o)
get Getter Method Names
List<String> methodNames = new ArrayList<>();
for (Method m : o.getClass().getMethods()) {
    if (m.getName().startsWith(GET_ROOT) || m.getName().startsWith(IS_ROOT)) {
        methodNames.add(m.getName());
return methodNames;