Java Reflection Method Setter Get getSetterMethods(Class clazz)

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

Description

get Setter Methods

License

Apache License

Declaration

public static List<Method> getSetterMethods(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 SETTER_METHOD_NAME_PATTERN = Pattern.compile("^set[A-Z]");

    public static List<Method> getSetterMethods(Class<?> clazz) {
        List<Method> props = new ArrayList<Method>();
        for (Method method : clazz.getMethods()) {
            String methodName = method.getName();
            if (SETTER_METHOD_NAME_PATTERN.matcher(methodName).find() && method.getParameterTypes().length == 1) {
                props.add(method);/*from  www .jav  a2s . c  o m*/
            }
        }

        return props;
    }
}

Related

  1. getSetterMethodByProperty(String propertyName, Class beanClass, Class setterParamType)
  2. getSetterMethodForClass(Class cls, String beanName, Class type)
  3. getSetterMethodFromGetter(final Method getter)
  4. getSetterMethods(Class clazz)
  5. getSetterMethods(Class clazz)
  6. getSetterMethods(Class objectType)
  7. getSetterMethods(Class pojoClass)
  8. getSetterMethods(final Class clazz)
  9. getSetterName(Field field)