Class ClassUtils

java.lang.Object
org.assertj.core.util.introspection.ClassUtils

public class ClassUtils extends Object
  • Constructor Details

    • ClassUtils

      public ClassUtils()
  • Method Details

    • getAllSuperclasses

      public static List<Class<?>> getAllSuperclasses(Class<?> cls)

      Gets a List of superclasses for the given class.

      Parameters:
      cls - the class to look up, may be null
      Returns:
      the List of superclasses in order going up from this one null if null input
    • getAllInterfaces

      public static List<Class<?>> getAllInterfaces(Class<?> cls)

      Gets a List of all interfaces implemented by the given class and its superclasses.

      The order is determined by looking through each interface in turn as declared in the source file and following its hierarchy up. Then each superclass is considered in the same way. Later duplicates are ignored, so the order is maintained.

      Parameters:
      cls - the class to look up, may be null
      Returns:
      the List of interfaces in order, null if null input
    • isPrimitiveOrWrapper

      public static boolean isPrimitiveOrWrapper(Class<?> type)
      Returns whether the given type is a primitive or primitive wrapper (Boolean, Byte, Character, Short, Integer, Long, Double, Float, Void).

      Returns false if passed null since the method can't evaluate the class.

      Inspired from apache commons-lang ClassUtils

      Parameters:
      type - The class to query or null.
      Returns:
      true if the given type is a primitive or primitive wrapper (Boolean, Byte, Character, Short, Integer, Long, Double, Float, Void).
      Since:
      3.24.0
    • isOptionalOrPrimitiveOptional

      public static boolean isOptionalOrPrimitiveOptional(Class<?> type)
      Returns whether the given type is a primitive or primitive wrapper (Optional, OptionalInt, OptionalLong, OptionalDouble).

      Returns false if passed null since the method can't evaluate the class.

      Parameters:
      type - The class to query or null.
      Returns:
      true if the given type is a primitive or primitive wrapper (Optional, OptionalInt, OptionalLong, OptionalDouble).
      Since:
      3.24.0