Class Primitives

java.lang.Object
revxrsal.commands.util.Primitives

public final class Primitives extends Object
A utility class for dealing with wrapping and unwrapping of primitive types
  • Method Details

    • getType

      public static Class<?> getType(@NotNull @NotNull Object o)
      Returns the type of the given object
      Parameters:
      o - Object to get for
      Returns:
      The object type
    • wrap

      public static <T> Class<T> wrap(Class<T> type)
      Returns the corresponding wrapper type of type if it is a primitive type; otherwise returns the type itself.
           wrap(int.class) == Integer.class
           wrap(Integer.class) == Integer.class
           wrap(String.class) == String.class
       
    • wrapType

      public static Type wrapType(Type type)
    • unwrap

      public static <T> Class<T> unwrap(Class<T> type)
      Returns the corresponding primitive type of type if it is a wrapper type; otherwise returns the type itself.
           unwrap(Integer.class) == int.class
           unwrap(int.class) == int.class
           unwrap(String.class) == String.class
       
    • isWrapperType

      public static boolean isWrapperType(Class<?> type)
      Returns true if the specified type is one of the nine primitive-wrapper types, such as Integer.
      Parameters:
      type - Type to check
      See Also:
    • getRawType

      public static Class<?> getRawType(Type type)
    • getInsideGeneric

      public static Type getInsideGeneric(Type genericType, Type fallback)