net.craftforge.reflection.utils
Class ClassUtils

java.lang.Object
  extended by net.craftforge.reflection.utils.ClassUtils

public class ClassUtils
extends Object

Provides utilities for class-related reflection operations.

Since:
02.12.2010
Author:
Christian Bick

Constructor Summary
ClassUtils()
           
 
Method Summary
static List<Class<?>> getClassHierarchy(Class<?> c)
          Gets a class hierarchy of a class as a list containing the class itself and all its super classes except of java.lang.Object.
static Method getFirstImplementation(Class<?> c, Method method)
          Looks for the first implementation or overriding of a method within the class hierarchy of the given class.
static List<Class<?>> getInterfaceHierarchy(Class<?> c)
          Gets a interface hierarchy of a class as a list containing the class's implemented interfaces and all their super interfaces.
static boolean isMethodExchangeableBy(Method method, Method candidateMethod)
          Compares the name and parameters of both methods with each other and looks for the method parameters to be compatible with the candidate method parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassUtils

public ClassUtils()
Method Detail

getClassHierarchy

public static List<Class<?>> getClassHierarchy(Class<?> c)
Gets a class hierarchy of a class as a list containing the class itself and all its super classes except of java.lang.Object. (bottom up)

Parameters:
c - The class
Returns:
List containing the class and all its super classes except of java.lang.Object

getInterfaceHierarchy

public static List<Class<?>> getInterfaceHierarchy(Class<?> c)
Gets a interface hierarchy of a class as a list containing the class's implemented interfaces and all their super interfaces. (bottom up)

Parameters:
c - The class
Returns:
List of classes that represent the interfaces

getFirstImplementation

public static Method getFirstImplementation(Class<?> c,
                                            Method method)
Looks for the first implementation or overriding of a method within the class hierarchy of the given class.

Parameters:
c - The class to look within the class hierarchy
method - The implemented or overridden method
Returns:
The first found implementing or overriding method

isMethodExchangeableBy

public static boolean isMethodExchangeableBy(Method method,
                                             Method candidateMethod)
Compares the name and parameters of both methods with each other and looks for the method parameters to be compatible with the candidate method parameters. Treats generic types as wild cards for any kind of type.

Parameters:
method - The method
candidateMethod - The candidate method
Returns:
true, if the method parameters are compatible, false otherwise


Copyright © 2011. All Rights Reserved.