Java Reflection Method Getter Get getGetterMethods(Class clazz)

Here you can find the source of getGetterMethods(Class clazz)

Description

get Getter Methods

License

Apache License

Declaration

public static List<Method> getGetterMethods(Class<?> clazz) 

Method Source Code


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

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

import java.util.List;

import java.util.regex.Pattern;

public class Main {

    private static final Pattern GETTER_METHOD_NAME_PATTERN = Pattern.compile("^get[A-Z]");

    public static List<Method> getGetterMethods(Class<?> clazz) {
        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);//  w ww  .  ja  va  2  s.co  m
            }
        }
        return props;
    }
}

Related

  1. getGetterMethodName(String fieldName, java.lang.Class fieldType)
  2. getGetterMethodName(String property, String javaType)
  3. getGetterMethodNames(Object o)
  4. getGetterMethods(Class clazz)
  5. getGetterMethods(Class clazz)
  6. getGetterMethods(Class objectType)
  7. getGetterMethods(Class pojoClass)
  8. getGetterMethods(final Class clazz)
  9. getGetterName(Field field)