Class PioneerUtils


  • public class PioneerUtils
    extends java.lang.Object
    Pioneer-internal utility class. DO NOT USE THIS CLASS - IT MAY CHANGE SIGNIFICANTLY IN ANY MINOR UPDATE.
    See Also:
    PioneerAnnotationUtils
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private PioneerUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static <T> void addButThrowIfDuplicate​(java.util.Set<T> set, T element)  
      static java.util.List<java.util.List<?>> cartesianProduct​(java.util.List<java.util.List<?>> lists)  
      static java.util.Locale createLocale​(java.lang.String language)  
      static java.util.Locale createLocale​(java.lang.String language, java.lang.String country)  
      static java.util.Locale createLocale​(java.lang.String language, java.lang.String country, java.lang.String variant)  
      static <T> java.util.stream.Collector<T,​java.util.Set<T>,​java.util.Set<T>> distinctToSet()
      A toSet collector that throws an IllegalStateException on duplicate elements (according to equals).
      static java.util.List<org.junit.jupiter.api.extension.ExtensionContext> findAllContexts​(org.junit.jupiter.api.extension.ExtensionContext context)
      Find all (parent) ExtensionContexts via ExtensionContext.getParent().
      static java.util.Optional<java.lang.reflect.Method> findMethodCurrentOrEnclosing​(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.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.
      static java.lang.String nullSafeToString​(java.lang.Object object)  
      static <T> java.lang.Class<T> wrap​(java.lang.Class<T> clazz)
      Replaces all primitive types with the appropriate wrapper types.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PioneerUtils

        private PioneerUtils()
    • Method Detail

      • distinctToSet

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

        private static <T> void addButThrowIfDuplicate​(java.util.Set<T> set,
                                                       T element)
      • findMethodCurrentOrEnclosing

        public static java.util.Optional<java.lang.reflect.Method> findMethodCurrentOrEnclosing​(java.lang.Class<?> clazz,
                                                                                                java.lang.String methodName,
                                                                                                java.lang.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:
        ReflectionSupport.findMethod(Class, String, Class...)
      • findAllContexts

        public static java.util.List<org.junit.jupiter.api.extension.ExtensionContext> findAllContexts​(org.junit.jupiter.api.extension.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 java.lang.String nullSafeToString​(java.lang.Object object)
      • wrap

        public static <T> java.lang.Class<T> wrap​(java.lang.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:
        MethodType.wrap()
      • cartesianProduct

        public static java.util.List<java.util.List<?>> cartesianProduct​(java.util.List<java.util.List<?>> lists)
      • createLocale

        public static java.util.Locale createLocale​(java.lang.String language,
                                                    java.lang.String country,
                                                    java.lang.String variant)
      • createLocale

        public static java.util.Locale createLocale​(java.lang.String language,
                                                    java.lang.String country)
      • createLocale

        public static java.util.Locale createLocale​(java.lang.String language)