Top Fields Constructors Methods
org.assertj.core.util.introspection

public Class ClassUtils

extends Object
Class Inheritance
Static Imports
org.assertj.core.util.Lists.list

Field Summary

Modifier and TypeField and Description
private static final List<Class<?>>
private static final List<Class<?>>
PRIMITIVE_WRAPPER_TYPES

Lists primitive wrapper Classes.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static List<Class<?>>

Returns:

the List of interfaces in order, null if null input
getAllInterfaces
(Class<?>
the class to look up, may be null
cls
)

Gets a List of all interfaces implemented by the given class and its superclasses.

pack-priv static void
getAllInterfaces(Class<?>
the class to look up, may be null
cls
,
HashSet<Class<?>>
the Set of interfaces for the class
interfacesFound
)

Get the interfaces for the specified class.

public static List<Class<?>>

Returns:

the List of superclasses in order going up from this one null if null input
getAllSuperclasses
(final Class<?>
the class to look up, may be null
cls
)

Gets a List of superclasses for the given class.

public static boolean

Returns:

true the given type belongs to the java.lang package itself or one of its subpackage, false otherwise.
isInJavaLangPackage
(final Class<?>
The class to check or null.
type
)

Returns whether the given type belongs to the java.lang package itself or one of its subpackage.

public static boolean

Returns:

true if the given type is a primitive or primitive wrapper (Optional, OptionalInt, OptionalLong, OptionalDouble).
isOptionalOrPrimitiveOptional
(final Class<?>
The class to query or null.
type
)

Returns whether the given type is a primitive or primitive wrapper (Optional, OptionalInt, OptionalLong, OptionalDouble).

public static boolean

Returns:

true if the given type is a primitive or primitive wrapper (Boolean, Byte, Character, Short, Integer, Long, Double, Float, Void).
isPrimitiveOrWrapper
(final Class<?>
The class to query or null.
type
)

Returns whether the given type is a primitive or primitive wrapper (Boolean, Byte, Character, Short, Integer, Long, Double, Float, Void).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

OPTIONAL_TYPESback to summary
private static final List<Class<?>> OPTIONAL_TYPES
PRIMITIVE_WRAPPER_TYPESback to summary
private static final List<Class<?>> PRIMITIVE_WRAPPER_TYPES

Lists primitive wrapper Classes.

Constructor Detail

ClassUtilsback to summary
public ClassUtils()

Method Detail

getAllInterfacesback to summary
public static List<Class<?>> getAllInterfaces(Class<?> cls)

Gets a List of 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:Class<?>

the class to look up, may be null

Returns:List<Class<?>>

the List of interfaces in order, null if null input

getAllInterfacesback to summary
pack-priv static void getAllInterfaces(Class<?> cls, HashSet<Class<?>> interfacesFound)

Get the interfaces for the specified class.

Parameters
cls:Class<?>

the class to look up, may be null

interfacesFound:HashSet<Class<?>>

the Set of interfaces for the class

getAllSuperclassesback to summary
public static List<Class<?>> getAllSuperclasses(final Class<?> cls)

Gets a List of superclasses for the given class.

Parameters
cls:Class<?>

the class to look up, may be null

Returns:List<Class<?>>

the List of superclasses in order going up from this one null if null input

isInJavaLangPackageback to summary
public static boolean isInJavaLangPackage(final Class<?> type)

Returns whether the given type belongs to the java.lang package itself or one of its subpackage.

Parameters
type:Class<?>

The class to check or null.

Returns:boolean

true the given type belongs to the java.lang package itself or one of its subpackage, false otherwise.

Since
3.25.0
isOptionalOrPrimitiveOptionalback to summary
public static boolean isOptionalOrPrimitiveOptional(final Class<?> type)

Returns whether the given type is a primitive or primitive wrapper (Optional, OptionalInt, OptionalLong, OptionalDouble).

Returns false if passed null since the method can't evaluate the class.

Parameters
type:Class<?>

The class to query or null.

Returns:boolean

true if the given type is a primitive or primitive wrapper (Optional, OptionalInt, OptionalLong, OptionalDouble).

Since
3.24.0
isPrimitiveOrWrapperback to summary
public static boolean isPrimitiveOrWrapper(final Class<?> type)

Returns whether the given type is 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:Class<?>

The class to query or null.

Returns:boolean

true if the given type is a primitive or primitive wrapper (Boolean, Byte, Character, Short, Integer, Long, Double, Float, Void).

Since
3.24.0