java.lang.Object
ushiosan.jvm_utilities.lang.Cls

public final class Cls extends Object
Class containing helper methods for working with objects of type Class
  • Method Details

    • isPrimitive

      public static boolean isPrimitive(@NotNull @NotNull Class<?> clazz)
      Checks whether the class of the argument is of some primitive type or some wrapper class corresponding to the primitive type.
      Parameters:
      clazz - the class to inspect
      Returns:
      true if the class is a primitive type or false otherwise
    • isPrimitive

      public static boolean isPrimitive(@NotNull @NotNull Object obj)
      Checks whether the class of the argument is of some primitive type or some wrapper class corresponding to the primitive type.
      Parameters:
      obj - the object to inspect
      Returns:
      true if the class is a primitive type or false otherwise
    • isPrimitiveArray

      public static boolean isPrimitiveArray(@NotNull @NotNull Class<?> clazz)
      Checks if the class of the argument is of some primitive type or some wrapper class corresponding to the primitive type (version for arrays).
      Parameters:
      clazz - the class to inspect
      Returns:
      true if the class is a primitive type or false otherwise
    • isPrimitiveArray

      public static boolean isPrimitiveArray(@NotNull @NotNull Object obj)
      Checks if the class of the argument is of some primitive type or some wrapper class corresponding to the primitive type (version for arrays).
      Parameters:
      obj - the object to inspect
      Returns:
      true if the class is a primitive type or false otherwise
    • toTypeArgs

      public static Class<?> @NotNull [] toTypeArgs(Object @NotNull ... args)
      Returns the type of all data passed as arguments
      Parameters:
      args - the arguments to convert
      Returns:
      an array with all element types
    • getArrayIndividualClass

      @NotNull public static <T> @NotNull Class<T> getArrayIndividualClass(T @NotNull [] array)
      Returns the class of the individual object in an array.

      Example:

      
       String[] array = new String[] {"Hello", "World", "!"};
       Class<?> cls = Cls.getArrayIndividualClass(array);
      
       // Output -> class java.lang.String
       
      Type Parameters:
      T - the class of the data type
      Parameters:
      array - the array you want to identify
      Returns:
      the data type of the elements individually
    • getArrayIndividualClass

      @NotNull public static <T> @NotNull Class<T> getArrayIndividualClass(T @NotNull [] @NotNull [] array)
      Returns the class of the individual object in an array.

      Example:

      
       String[][] array = new String[0][0];
       Class<?> cls = Cls.getArrayIndividualClass(array);
      
       // Output -> class java.lang.String
       
      Type Parameters:
      T - the class of the data type
      Parameters:
      array - the array you want to identify
      Returns:
      the data type of the elements individually
    • getArrayMultipleIndividualClass

      @NotNull public static <T> @NotNull Class<T> getArrayMultipleIndividualClass(@NotNull @NotNull Object array)
      Returns the class of the individual object in an array.

      Example:

      
       String[][][] array = new String[0][0][0]; // or more
       Class<?> cls = Cls.getArrayIndividualClass(array);
      
       // Output -> class java.lang.String
       
      Type Parameters:
      T - the class of the data type
      Parameters:
      array - the array you want to identify
      Returns:
      the data type of the elements individually