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

MapgetGetterMethods(Class clazz)
get Getter Methods
if (isPrimite(clazz)) {
    return Collections.emptyMap();
Map<String, Method> result = cache.get(clazz);
if (result == null) {
    result = createGetterMethods(clazz);
    cache.put(clazz, result);
return result;
ListgetGetterMethods(Class clazz)
get Getter Methods
List<Method> allMethods = new ArrayList<Method>();
do {
    try {
        allMethods.addAll(Arrays.asList(clazz.getDeclaredMethods()));
    } catch (Exception e) {
} while ((clazz = clazz.getSuperclass()).getPackage().getName().startsWith("net.freedom.gj.example"));
List<Method> getterMethods = new ArrayList<Method>();
...
ListgetGetterMethods(Class clazz)
get Getter Methods
List<Method> props = new ArrayList<Method>();
for (Method method : clazz.getMethods()) {
    String methodName = method.getName();
    if (!methodName.equals("getClass") && GETTER_METHOD_NAME_PATTERN.matcher(methodName).find()) {
        props.add(method);
return props;
...
ListgetGetterMethods(Class objectType)
get Getter Methods
List<Method> result = new ArrayList<Method>();
Method[] methods = objectType.getMethods();
for (Method method : methods) {
    if (isValidGetterMethod(method)) {
        result.add(method);
return result;
...
MapgetGetterMethods(Class pojoClass)
Gets the getters of a pojo as a map of String as key and Method as value.
HashMap<String, Method> methods = new HashMap<String, Method>();
fillGetterMethods(pojoClass, methods);
return methods;
ListgetGetterMethods(final Class clazz)
get Getter Methods
final List<Method> result = new ArrayList<Method>();
for (Method m : clazz.getMethods()) {
    if (m.getName().startsWith("get")) {
        if (m.getParameterTypes().length == 0) {
            result.add(m);
return result;
StringgetGetterName(Field field)
get Getter Name
String name = field.getName();
if (field.getType().equals(boolean.class)) {
    return "is" + name.substring(0, 1).toUpperCase(Locale.US) + name.substring(1);
} else {
    return "get" + name.substring(0, 1).toUpperCase(Locale.US) + name.substring(1);
StringgetGetterName(Field field)
get Getter Name
char[] fieldNameChars = field.getName().toCharArray();
fieldNameChars[0] = Character.toUpperCase(fieldNameChars[0]);
String accessor = isBoolean(field.getType()) ? IS_ACCESSOR : GET_ACCESSOR;
return accessor.concat(String.valueOf(fieldNameChars));
StringgetGetterName(final Field field)
get Getter Name
return "get" + capitalizeFieldName(field);
StringgetGetterName(Method m)
get Getter Name
String name = m.getName();
if (name.substring(0, 3).equals("get"))
    name = name.substring(3);
else if (name.substring(0, 2).equals("is"))
    name = name.substring(2);
return name;