Class ClassWalker

java.lang.Object
xyz.dynxsty.dih4jda.util.ClassWalker

public class ClassWalker extends Object
A class that provides you with the ability to get all classes inside a specific package.
Since:
v1.6
  • Constructor Summary

    Constructors
    Constructor
    Description
    ClassWalker(String packageName)
    Creates a new instance that allows you to perform reflective operations for the defined package.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets all classes inside the given package and sub packages.
    <T> Set<Class<? extends T>>
    Gets all classes in the given package and sub packages which extend the specified class.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ClassWalker

      public ClassWalker(@Nonnull String packageName)
      Creates a new instance that allows you to perform reflective operations for the defined package.
      Parameters:
      packageName - the package you want to perform operations on.
  • Method Details

    • getAllClasses

      @Nonnull public Set<Class<?>> getAllClasses() throws DIH4JDAException
      Gets all classes inside the given package and sub packages.
      Returns:
      An unmodifiable Set of classes inside the given package.
      Throws:
      DIH4JDAException - is thrown if anything happens during this reflection operation.
      Since:
      v1.6
    • getSubTypesOf

      @Nonnull public <T> Set<Class<? extends T>> getSubTypesOf(@Nonnull Class<T> type) throws DIH4JDAException
      Gets all classes in the given package and sub packages which extend the specified class.
      Type Parameters:
      T - the instance of the class that was provided as a type.
      Parameters:
      type - The parent class to search for.
      Returns:
      an unmodifiable Set of classes which are assignable to the given type.
      Throws:
      DIH4JDAException - is thrown by getAllClasses().
      Since:
      v1.6