Here you can find the source of getGetters(Class> c)
Parameter | Description |
---|---|
c | The class. |
public static List<Method> getGetters(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 ww w . jav a2 s .c o m * Finds the getters of a class. * * @param c * The class. * @return The getters of the class. */ public static List<Method> getGetters(Class<?> c) { Method[] allMethods = c.getDeclaredMethods(); List<Method> getters = new LinkedList<>(); for (Method m : allMethods) { if (((m.getReturnType().equals(boolean.class) && m.getName().startsWith("is")) || m.getName().startsWith("get")) && m.getParameterTypes().length == 0) { getters.add(m); } } return getters; } }