Java Reflection Method Setter Get getSetters(Object obj)

Here you can find the source of getSetters(Object obj)

Description

get Setters

License

Open Source License

Declaration

public static List<Method> getSetters(Object obj) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.*;
import java.util.*;

public class Main {
    public static List<Method> getSetters(Object obj) {
        List<Method> ret = new ArrayList<Method>();
        for (Method method : obj.getClass().getMethods()) {
            int mod = method.getModifiers();
            if (Modifier.isStatic(mod) || !Modifier.isPublic(mod))
                continue;
            if (method.getParameterTypes().length != 1 || method.getReturnType() != Void.TYPE)
                continue;
            String name = method.getName();
            if (!name.startsWith("set"))
                continue;

            ret.add(method);//from  w  w w .  j  a v  a  2  s .  c o m
        }
        return ret;
    }
}

Related

  1. getSetters(Class klass)
  2. getSetters(Class c)
  3. getSetters(Class clazz)
  4. getSetters(Class clazz)
  5. getSetters(Class klass)
  6. getSettersForType(Class clazz, String typeName)
  7. getSetterShorthandName(Method method)
  8. getSetterType(Method method)