Package panda.utilities
Class ClassUtils
java.lang.Object
panda.utilities.ClassUtils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanCheck if the class exists usingforName(String)static <T> panda.std.Option<Class<? extends T>>Get class usingClass.forName(String)asOptionstatic Class<?>[]getClasses(Object... values) Get classes of the given valuesstatic Class<?>getNonPrimitiveClass(Class<?> clazz) Get non primitive classstatic booleanisAssignableFrom(@Nullable Class<?> toClass, @Nullable Class<?> fromClass) Check if the class is assignable to another with primitive types supportstatic booleanisAssignableFrom(Class<?> toClass, @Nullable Object fromObject) Check if the class is assignable to another with primitive types support.static panda.std.Option<Class<?>>selectMostRelated(Collection<? extends Class<?>> classes, Class<?> to) Select the most related class from the specified collection
-
Field Details
-
PRIMITIVE_EQUIVALENT
-
-
Method Details
-
getNonPrimitiveClass
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 into- the class to compare with- Returns:
- the most related class from collection (may not exist)
-
isAssignableFrom
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 classfromClass- theClassobject to be checked- Returns:
- true if toClass is assignable to fromClass
-
getClasses
Get classes of the given values- Parameters:
values- the values to check- Returns:
- array of classes
-
exists
Check if the class exists usingforName(String)- Parameters:
name- the name of class- Returns:
- true if class exists, otherwise false
-
forName
Get class usingClass.forName(String)asOption- Parameters:
name- the name of class- Returns:
- optional with class (with null instead of
ClassNotFoundException)
-