Class PioneerUtils

java.lang.Object
org.junitpioneer.internal.PioneerUtils

public class PioneerUtils extends Object
Pioneer-internal utility class. DO NOT USE THIS CLASS - IT MAY CHANGE SIGNIFICANTLY IN ANY MINOR UPDATE.
See Also:
  • Method Details

    • distinctToSet

      public static <T> Collector<T,Set<T>,Set<T>> distinctToSet()
      A toSet collector that throws an IllegalStateException on duplicate elements (according to equals).
    • findMethodCurrentOrEnclosing

      public static Optional<Method> findMethodCurrentOrEnclosing(Class<?> clazz, String methodName, Class<?>... parameterTypes)
      Find the first Method of the supplied class or interface that meets the specified criteria, beginning with the specified class or interface and traversing its enclosing classes until such a method is found or the top level class is reached.

      The algorithm does not search for methods in Object.

      Parameters:
      clazz - the class or interface in which to find the method; never null
      methodName - the name of the method to find; never null or empty
      parameterTypes - the types of parameters accepted by the method, if any; never null
      Returns:
      an Optional containing the method found; never null but potentially empty if no such method could be found
      See Also:
    • findAllContexts

      public static List<ExtensionContext> findAllContexts(ExtensionContext context)
      Find all (parent) ExtensionContexts via ExtensionContext.getParent().
      Parameters:
      context - the context for which to find all (parent) contexts; never null
      Returns:
      a list of all contexts, "outwards" in the getParent-order, beginning with the given context; never null or empty
    • nullSafeToString

      public static String nullSafeToString(Object object)
    • wrap

      public static <T> Class<T> wrap(Class<T> clazz)
      Replaces all primitive types with the appropriate wrapper types. Returns the passed argument if it's not a primitive according to Class.isPrimitive().
      Returns:
      the wrapped class of the primitive type, or the passed class
      See Also:
    • cartesianProduct

      public static List<List<?>> cartesianProduct(List<List<?>> lists)