Java Reflection Method Setter Get getSetterMethods(Class clazz)

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

Description

get Setter Methods

License

Open Source License

Declaration

public static Method[] getSetterMethods(Class<?> clazz) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static Method[] getSetterMethods(Class<?> clazz) {
        if (clazz == null) {
            return new Method[] {};
        }//w  w w. j  a  v  a 2s.  c  o  m
        Method[] methods = clazz.getMethods();
        List<Method> mlist = new ArrayList<Method>();
        for (int i = 0; i < methods.length; i++) {
            Method method = methods[i];
            String methodName = method.getName();
            if (methodName.startsWith("set")) { //$NON-NLS-1$
                mlist.add(method);
            }
        }
        return mlist.toArray(new Method[] {});
    }
}

Related

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