java.lang.Object
ushiosan.jvm.internal.validators.UClassValidator
ushiosan.jvm.UClass
Class containing helper methods for working with objects of type
Class-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intProperty used to return only the current class from the inheritance stack.static final intProperty used to return the entire inheritance stack of a class.Fields inherited from class ushiosan.jvm.internal.validators.UClassValidator
INVALID_GET_TYPES, PRIMITIVE_ARRAY_CLASSES, PRIMITIVE_ARRAY_INDIVIDUAL, PRIMITIVE_WRAPPED_CLASSES -
Method Summary
Modifier and TypeMethodDescriptionclassStack(@NotNull Class<?> cls) Returns the inheritance of a class recursively.classStack(@NotNull Class<?> cls, int maxDeep) Returns the inheritance of a class recursively.getArrayIndividualClass(T @NotNull [] array) Returns the class of the individual object in an array.getArrayIndividualClass(T @NotNull [] @NotNull [] array) Returns the class of the individual object in an array.Returns the class of the individual object in an array.static booleanisArrayPrimitive(@NotNull Class<?> cls) Checks if the class of the argument is of some primitive type or some wrapper class corresponding to the primitive type (version for arrays).static booleanChecks if the class of the argument is of some primitive type or some wrapper class corresponding to the primitive type (version for arrays).static booleanisPrimitive(@NotNull Class<?> cls) Checks whether the class of the argument is of some primitive type or some wrapper class corresponding to the primitive type.static booleanisPrimitive(@Nullable Object obj) Checks whether the class of the argument is of some primitive type or some wrapper class corresponding to the primitive type.toVarargTypes(Object... args) Returns the data type of all passed elements.
-
Field Details
-
FULL_CLASS_STACK
public static final int FULL_CLASS_STACKProperty used to return the entire inheritance stack of a class.- See Also:
-
ALONE_CLASS_STACK
public static final int ALONE_CLASS_STACKProperty used to return only the current class from the inheritance stack.- See Also:
-
-
Method Details
-
isPrimitive
Checks whether the class of the argument is of some primitive type or some wrapper class corresponding to the primitive type.- Parameters:
cls- the class to inspect- Returns:
trueif the class is a primitive type orfalseotherwise
-
isPrimitive
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:
trueif the class is a primitive type orfalseotherwise
-
classStack
@NotNull public static @NotNull Stack<Class<?>> classStack(@NotNull @NotNull Class<?> cls, int maxDeep) Returns the inheritance of a class recursively. In this way, it is possible to know from how many classes a class inherits functionalities. Although it is possible to only obtain a certain number of elements of that inheritance.- Parameters:
cls- the class you want to inspectmaxDeep- the inheritance boundary that you want to traverse. In addition to the limit, there are 2 special cases, which are used for other behavior:- Case 0: This case makes the inheritance recursive until reaching the "Object" class, which is the limit of all Java classes.
- Case 1: This case causes only the current class to be listed and no other.
- Returns:
- a stack with all the inheritance elements of the chosen class
- See Also:
-
classStack
Returns the inheritance of a class recursively. In this way, it is possible to know from how many classes a class inherits functionalities. Although it is possible to only obtain a certain number of elements of that inheritance.- Parameters:
cls- the class you want to inspect- Returns:
- a stack with all the inheritance elements of the chosen class
-
isArrayPrimitive
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:
cls- the class to inspect- Returns:
trueif the class is a primitive type orfalseotherwise
-
isArrayPrimitive
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:
trueif the class is a primitive type orfalseotherwise
-
getArrayIndividualClass
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
-
toVarargTypes
Returns the data type of all passed elements. This method is useful for knowing through reflection which method you want to call.- Parameters:
args- the arguments to convert- Returns:
- an array with all element types
-