Java Reflection Method Getter Get getGetterMethodNames(Object o)

Here you can find the source of getGetterMethodNames(Object o)

Description

get Getter Method Names

License

Apache License

Declaration

public static List<String> getGetterMethodNames(Object o) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

public class Main {
    private static final String GET_ROOT = "get";
    private static final String IS_ROOT = "is";

    public static List<String> getGetterMethodNames(Object o) {
        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());
            }//from ww w .j av  a 2  s .c  o m
        }
        return methodNames;
    }
}

Related

  1. getGetterMethod(String getterName, Object bean, Class returnType)
  2. getGetterMethodByProperty(String propertyName, Class beanClass, Class returnType)
  3. getGetterMethodForClass(Class cls, String beanName)
  4. getGetterMethodName(String fieldName, java.lang.Class fieldType)
  5. getGetterMethodName(String property, String javaType)
  6. getGetterMethods(Class clazz)
  7. getGetterMethods(Class clazz)
  8. getGetterMethods(Class clazz)
  9. getGetterMethods(Class objectType)