public static List < Method > getClassSetters ( Class < ? > beanClass ) { Map < String , Method > result = new HashMap <> ( ) ; Class < ? > currentClass = beanClass ; while ( currentClass != null && currentClass != Object . class ) { for ( Method method : currentClass . getDeclaredMethods ( ) ) { if ( ! method . isSynthetic ( ) && isSetter ( method ) ) { result . putIfAbsent ( method . getName ( ) , method ) ; } } currentClass = currentClass . getSuperclass ( ) ; } return new LinkedList <> ( result . values ( ) ) ; }
Return a list of class setters . Supports inheritance and overriding that is when a method is found on the lowest level of inheritance chain no other method can override it . Supports inheritance and doesn t return synthetic methods .