Class ClassUtils
- java.lang.Object
-
- io.smallrye.reactive.messaging.providers.helpers.ClassUtils
-
public class ClassUtils extends Object
Allows checking if a class can be assigned to a variable from another class. Code extracted from from Apache Commons Lang 3 - ClassUtils.java
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isAssignable(Class<?> cls, Class<?> toClass)
Checks if onecls
can be assigned to a variable of anothertoClass
, like:Cls c = ...; ToClass x = c;
static Class<?>
primitiveToWrapper(Class<?> cls)
Converts the specified primitive Class object to its corresponding wrapper Class object.
-
-
-
Method Detail
-
isAssignable
public static boolean isAssignable(Class<?> cls, Class<?> toClass)
Checks if onecls
can be assigned to a variable of anothertoClass
, like:Cls c = ...; ToClass x = c;
- Parameters:
cls
- the Class to check, may benull
toClass
- the Class to try to assign into, returnsfalse
if null- Returns:
true
if assignment possible
-
primitiveToWrapper
public static Class<?> primitiveToWrapper(Class<?> cls)
Converts the specified primitive Class object to its corresponding wrapper Class object.
NOTE: From v2.2, this method handles
Void.TYPE
, returningVoid.TYPE
.- Parameters:
cls
- the class to convert, may be null- Returns:
- the wrapper class for
cls
orcls
ifcls
is not a primitive.null
if null input. - Since:
- 2.1
-
-