Class ClassUtils

java.lang.Object
panda.utilities.ClassUtils

public final class ClassUtils extends Object
  • Field Details

    • PRIMITIVE_EQUIVALENT

      public static final Map<Class<?>,Class<?>> PRIMITIVE_EQUIVALENT
  • Method Details

    • getNonPrimitiveClass

      public static Class<?> getNonPrimitiveClass(Class<?> clazz)
      Get non primitive class
      Parameters:
      clazz - the class to get
      Returns:
      non primitive class
    • selectMostRelated

      public static panda.std.Option<Class<?>> selectMostRelated(Collection<? extends Class<?>> classes, Class<?> to)
      Select the most related class from the specified collection
      Parameters:
      classes - the collection to search in
      to - the class to compare with
      Returns:
      the most related class from collection (may not exist)
    • isAssignableFrom

      public static boolean isAssignableFrom(Class<?> toClass, @Nullable @Nullable Object fromObject)
      Check if the class is assignable to another with primitive types support. Utility command for nullable fromObject.
      See Also:
    • isAssignableFrom

      public static boolean isAssignableFrom(@Nullable @Nullable Class<?> toClass, @Nullable @Nullable Class<?> fromClass)
      Check if the class is assignable to another with primitive types support
      Parameters:
      toClass - the root class
      fromClass - the Class object to be checked
      Returns:
      true if toClass is assignable to fromClass
    • getClasses

      public static Class<?>[] getClasses(Object... values)
      Get classes of the given values
      Parameters:
      values - the values to check
      Returns:
      array of classes
    • exists

      public static boolean exists(String name)
      Check if the class exists using forName(String)
      Parameters:
      name - the name of class
      Returns:
      true if class exists, otherwise false
    • forName

      public static <T> panda.std.Option<Class<? extends T>> forName(String name)
      Get class using Class.forName(String) as Option
      Parameters:
      name - the name of class
      Returns:
      optional with class (with null instead of ClassNotFoundException)