Class ClassUtils

java.lang.Object
org.skriptlang.skript.util.ClassUtils

public final class ClassUtils extends Object
Utilities for interacting with classes.
  • Constructor Details

    • ClassUtils

      public ClassUtils()
  • Method Details

    • isNormalClass

      public static boolean isNormalClass(Class<?> clazz)
      Parameters:
      clazz - The class to check.
      Returns:
      True if clazz does not represent an annotation, array, primitive, interface, or abstract class.
    • hierarchyDistance

      public static int hierarchyDistance(Class<?> a, Class<?> b)
      Calculates the distance between two classes in the inheritance hierarchy.
      Parameters:
      a - The superclass.
      b - The subclass.
      Returns:
      The distance between class a and class b. If a is not a superclass of b, returns -1. If a equals b, returns 0.
    • hierarchyDistanceBetween

      public static int hierarchyDistanceBetween(Class<?> a, Class<?> b)
      Calculates the distance between two classes in the inheritance hierarchy, in either direction.
      Parameters:
      a - The first class.
      b - The second class.
      Returns:
      The distance between class a and class b. If neither class is a superclass of the other, returns -1. If the classes are equal, returns 0.
    • isRelatedTo

      public static boolean isRelatedTo(Class<?> a, Class<?> b)
      Checks if two classes are related in the inheritance hierarchy.
      Parameters:
      a - The first class.
      b - The second class.
      Returns:
      True if either class is a superclass of the other.