Class ClassUtils
- java.lang.Object
-
- org.assertj.core.util.introspection.ClassUtils
-
public class ClassUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<java.lang.Class<?>>OPTIONAL_TYPESprivate static java.util.List<java.lang.Class<?>>PRIMITIVE_WRAPPER_TYPESLists primitive wrapperClasses.
-
Constructor Summary
Constructors Constructor Description ClassUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.List<java.lang.Class<?>>getAllInterfaces(java.lang.Class<?> cls)Gets aListof all interfaces implemented by the given class and its superclasses.(package private) static voidgetAllInterfaces(java.lang.Class<?> cls, java.util.HashSet<java.lang.Class<?>> interfacesFound)Get the interfaces for the specified class.static java.util.List<java.lang.Class<?>>getAllSuperclasses(java.lang.Class<?> cls)Gets aListof superclasses for the given class.static booleanisInJavaLangPackage(java.lang.Class<?> type)Returns whether the giventypebelongs to the java.lang package itself or one of its subpackage.static booleanisOptionalOrPrimitiveOptional(java.lang.Class<?> type)Returns whether the giventypeis a primitive or primitive wrapper (Optional,OptionalInt,OptionalLong,OptionalDouble).static booleanisPrimitiveOrWrapper(java.lang.Class<?> type)Returns whether the giventypeis a primitive or primitive wrapper (Boolean,Byte,Character,Short,Integer,Long,Double,Float,Void).
-
-
-
Method Detail
-
getAllSuperclasses
public static java.util.List<java.lang.Class<?>> getAllSuperclasses(java.lang.Class<?> cls)
Gets a
Listof superclasses for the given class.- Parameters:
cls- the class to look up, may benull- Returns:
- the
Listof superclasses in order going up from this onenullif null input
-
getAllInterfaces
public static java.util.List<java.lang.Class<?>> getAllInterfaces(java.lang.Class<?> cls)
Gets a
Listof all interfaces implemented by the given class and its superclasses.The order is determined by looking through each interface in turn as declared in the source file and following its hierarchy up. Then each superclass is considered in the same way. Later duplicates are ignored, so the order is maintained.
- Parameters:
cls- the class to look up, may benull- Returns:
- the
Listof interfaces in order,nullif null input
-
getAllInterfaces
static void getAllInterfaces(java.lang.Class<?> cls, java.util.HashSet<java.lang.Class<?>> interfacesFound)Get the interfaces for the specified class.- Parameters:
cls- the class to look up, may benullinterfacesFound- theSetof interfaces for the class
-
isPrimitiveOrWrapper
public static boolean isPrimitiveOrWrapper(java.lang.Class<?> type)
Returns whether the giventypeis a primitive or primitive wrapper (Boolean,Byte,Character,Short,Integer,Long,Double,Float,Void).Returns false if passed null since the method can't evaluate the class.
Inspired from apache commons-lang ClassUtils
- Parameters:
type- The class to query or null.- Returns:
- true if the given
typeis a primitive or primitive wrapper (Boolean,Byte,Character,Short,Integer,Long,Double,Float,Void). - Since:
- 3.24.0
-
isOptionalOrPrimitiveOptional
public static boolean isOptionalOrPrimitiveOptional(java.lang.Class<?> type)
Returns whether the giventypeis a primitive or primitive wrapper (Optional,OptionalInt,OptionalLong,OptionalDouble).Returns false if passed null since the method can't evaluate the class.
- Parameters:
type- The class to query or null.- Returns:
- true if the given
typeis a primitive or primitive wrapper (Optional,OptionalInt,OptionalLong,OptionalDouble). - Since:
- 3.24.0
-
isInJavaLangPackage
public static boolean isInJavaLangPackage(java.lang.Class<?> type)
Returns whether the giventypebelongs to the java.lang package itself or one of its subpackage.- Parameters:
type- The class to check or null.- Returns:
- true the given
typebelongs to the java.lang package itself or one of its subpackage, false otherwise. - Since:
- 3.25.0
-
-