Top Description Constructors Methods
org.junit.platform.commons.util

public final Class ClassUtils

extends Object
Class Inheritance
Annotations
@API
status:INTERNAL
since:1.0
Static Imports
java.util.Arrays.stream, java.util.stream.Collectors.joining, org.apiguardian.api.API.Status.INTERNAL

Collection of utilities for working with classes.

DISCLAIMER

These utilities are intended solely for usage within the JUnit framework itself. Any usage by external parties is not supported. Use at your own risk!

Since
1.0

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

the fully qualified class name or "null" if the supplied class reference is null
nullSafeToString
(@Nullable Class<?>
the class whose name should be retrieved, potentially null
clazz
)

Get the fully qualified name of the supplied class.

public static String

Returns:

a comma-separated list of fully qualified class names, or an empty string if the supplied class array is null or empty
nullSafeToString
(@Nullable @Nullable Class<?>...
the classes whose names should be included in the generated string
classes
)

Generate a comma-separated list of fully qualified class names for the supplied classes.

public static String

Returns:

a comma-separated list of mapped values, or an empty string if the supplied class array is null or empty
nullSafeToString
(Function<? super Class<?>, ? extends String>
the mapper to use; never null
mapper
,
@Nullable @Nullable Class<?>...
the classes to map
classes
)

Generate a comma-separated list of mapped values for the supplied classes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ClassUtilsback to summary
private ClassUtils()

Method Detail

nullSafeToStringback to summary
public static String nullSafeToString(@Nullable Class<?> clazz)

Get the fully qualified name of the supplied class.

This is a null-safe variant of Class#getName().

Parameters
clazz:@Nullable Class<?>

the class whose name should be retrieved, potentially null

Returns:String

the fully qualified class name or "null" if the supplied class reference is null

Since
1.3
See Also
nullSafeToString(Class...), StringUtils#nullSafeToString(Object)
nullSafeToStringback to summary
public static String nullSafeToString(@Nullable @Nullable Class<?>... classes)

Generate a comma-separated list of fully qualified class names for the supplied classes.

Parameters
classes:@Nullable @Nullable Class<?>[]

the classes whose names should be included in the generated string

Returns:String

a comma-separated list of fully qualified class names, or an empty string if the supplied class array is null or empty

See Also
nullSafeToString(Function, Class...), StringUtils#nullSafeToString(Object)
nullSafeToStringback to summary
public static String nullSafeToString(Function<? super Class<?>, ? extends String> mapper, @Nullable @Nullable Class<?>... classes)

Generate a comma-separated list of mapped values for the supplied classes.

The values are generated by the supplied mapper (e.g., Class::getName, Class::getSimpleName, etc.), unless a class reference is null in which case it will be mapped to "null".

Parameters
mapper:Function<? super Class<?>, ? extends String>

the mapper to use; never null

classes:@Nullable @Nullable Class<?>[]

the classes to map

Returns:String

a comma-separated list of mapped values, or an empty string if the supplied class array is null or empty

See Also
nullSafeToString(Class...), StringUtils#nullSafeToString(Object)