Class ClassUtils

java.lang.Object
org.junit.platform.commons.util.ClassUtils

@API(status=INTERNAL,
     since="1.0")
public final class ClassUtils
extends java.lang.Object
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
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String nullSafeToString​(java.lang.Class<?> clazz)
    Get the fully qualified name of the supplied class.
    static java.lang.String nullSafeToString​(java.lang.Class<?>... classes)
    Generate a comma-separated list of fully qualified class names for the supplied classes.
    static java.lang.String nullSafeToString​(java.util.function.Function<? super java.lang.Class<?>,​? extends java.lang.String> mapper, java.lang.Class<?>... classes)
    Generate a comma-separated list of mapped values for the supplied classes.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • nullSafeToString

      public static java.lang.String nullSafeToString​(java.lang.Class<?> clazz)
      Get the fully qualified name of the supplied class.

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

      Parameters:
      clazz - the class whose name should be retrieved, potentially null
      Returns:
      the fully qualified class name or "null" if the supplied class reference is null
      Since:
      1.3
      See Also:
      nullSafeToString(Class...), StringUtils.nullSafeToString(Object)
    • nullSafeToString

      public static java.lang.String nullSafeToString​(java.lang.Class<?>... classes)
      Generate a comma-separated list of fully qualified class names for the supplied classes.
      Parameters:
      classes - the classes whose names should be included in the generated string
      Returns:
      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)
    • nullSafeToString

      public static java.lang.String nullSafeToString​(java.util.function.Function<? super java.lang.Class<?>,​? extends java.lang.String> mapper, java.lang.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 - the mapper to use; never null
      classes - the classes to map
      Returns:
      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)