org.hibernate.validator.internal.util.classhierarchy
Class ClassHierarchyHelper

java.lang.Object
  extended by org.hibernate.validator.internal.util.classhierarchy.ClassHierarchyHelper

public class ClassHierarchyHelper
extends Object

Helper class for dealing with inheritance hierarchies of given types which allows to selectively retrieve elements from such hierarchies, e.g. all super-classes, all implemented interfaces etc.

Author:
Hardy Ferentschik, Gunnar Morling

Constructor Summary
ClassHierarchyHelper()
           
 
Method Summary
static List<Method> getAllMethods(Class<?> clazz)
          Get a list of all methods wich the given class declares, implements, overrides or inherits.
static
<T> Set<Class<? super T>>
getDirectlyImplementedInterfaces(Class<T> clazz)
          Gets all interfaces (and recursively their super-interfaces) which the given class directly implements.
static
<T> List<Class<? super T>>
getHierarchy(Class<T> clazz, Filter... filters)
          Gets the elements of the hierarchy of the given class which match the given filters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassHierarchyHelper

public ClassHierarchyHelper()
Method Detail

getHierarchy

public static <T> List<Class<? super T>> getHierarchy(Class<T> clazz,
                                                      Filter... filters)
Gets the elements of the hierarchy of the given class which match the given filters. Classes are added by starting with the class itself and its implemented interfaces. Then its super class and interfaces are added and so on.

Parameters:
clazz - the class for which to retrieve the hierarchy
filters - filters applying for the search
Returns:
List of hierarchy classes. Will only contain those types matching the given filters. The list contains the given class itself, if it is no proxy class.

getDirectlyImplementedInterfaces

public static <T> Set<Class<? super T>> getDirectlyImplementedInterfaces(Class<T> clazz)
Gets all interfaces (and recursively their super-interfaces) which the given class directly implements. Interfaces implemented by super-classes are not contained.

Parameters:
clazz - the class for which to retrieve the implemented interfaces
Returns:
Set of all interfaces implemented by the class represented by this hierarchy. The empty list is returned if it does not implement any interfaces.

getAllMethods

public static List<Method> getAllMethods(Class<?> clazz)
Get a list of all methods wich the given class declares, implements, overrides or inherits. Methods are added by adding first all methods of the class itself and its implemented interfaces, then the super class and its interfaces, etc.

Parameters:
clazz - the class for which to retrieve the methods
Returns:
set of all methods of the given class


Copyright © 2007-2013 Red Hat, Inc. All Rights Reserved