Class ClassHelper

java.lang.Object
de.qytera.qtaf.core.reflection.ClassHelper

public class ClassHelper extends Object
Utility class containing reflection methods dealing with Java classes.
  • Method Details

    • getSuperclasses

      public static Set<Class<?>> getSuperclasses(Object object, Class<?> stopAt)
      Return all superclasses of the given object until stopAt is reached.
      Parameters:
      object - The object that should be inspected
      stopAt - The final superclass at which the algorithm should stop
      Returns:
      a set of superclasses of the given object
    • getSuperclasses

      public static Set<Class<?>> getSuperclasses(Object object)
      Return all superclasses of a given object.
      Parameters:
      object - The object that should be inspected
      Returns:
      All superclasses of the object
    • getInterfaces

      public static Set<Class<?>> getInterfaces(Object object)
      Return all interfaces of a given object.
      Parameters:
      object - the object to inspect
      Returns:
      all interfaces of the object
    • getSuperclassesAndInterfaces

      public static Set<Class<?>> getSuperclassesAndInterfaces(Object object)
      Get all superclasses and all interfaces that an object implements.
      Parameters:
      object - The inspected object
      Returns:
      Set of all superclasses and implemented interfaces
    • parametersSuitableForMethod

      public static boolean parametersSuitableForMethod(Method m, Object[] params)
      Check if a provided list of parameters can be used for a given method.
      Parameters:
      m - The method that should be inspected
      params - The parameters that should be inspected
      Returns:
      True if the provided parameters can be used for the provided method
    • findSuitableMethods

      public static List<Method> findSuitableMethods(Class<?> clazz, Object[] params, String methodName)
      Find all methods in a class that match a given list of parameters. The parameters have to be provided in the order as they are passes to the method.
      Parameters:
      clazz - The class that should be inspected
      params - The parameters that should be provided to a method
      methodName - Optionally you can provide a method name here that the desired method should have, otherwise set this attribute to null
      Returns:
      All method that can handle the provided list of parameters