Here you can find the source of getSetters(Class> c)
Parameter | Description |
---|---|
c | The class. |
public static List<Method> getSetters(Class<?> c)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; import java.util.LinkedList; import java.util.List; public class Main { /**//from w ww . java 2 s .co m * Finds the setters of a class. * * @param c * The class. * @return The setters of the class. */ public static List<Method> getSetters(Class<?> c) { return getSetters(c, false); } private static List<Method> getSetters(Class<?> c, boolean flag) { Method[] allMethods = c.getDeclaredMethods(); List<Method> setters = new LinkedList<>(); for (Method m : allMethods) { Class<?>[] types = m.getParameterTypes(); if (m.getName().startsWith("set") && types.length == (flag ? 2 : 1)) { if ((flag && types[1].equals(boolean.class)) || !flag) { setters.add(m); } } } return setters; } }