Class ParameterUtils


  • public class ParameterUtils
    extends java.lang.Object
    A utility class for parameters read and processing.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NULL_VALUE  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String formatParametersAsTable​(java.util.List<ParameterResource> parameters)
      Format parameters as Markdown table.
      static <T> java.util.List<ParameterResource> getParameters​(java.lang.reflect.Executable method, java.util.List<T> parameterValues)
      Read all parameters from a method or a constructor and converts in into a list of ParameterResource.
      static <T> java.util.List<ParameterResource> getParameters​(java.lang.String codeRef, java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,​T>> parameters)
      Read all parameters from a method or a constructor and converts in into a list of ParameterResource.
      static java.lang.Class<?> toBoxedType​(java.lang.Class<?> primitiveType)
      Converts primitive type to a corresponding boxed class, or returns the same instance if the input is not primitive.
      • Methods inherited from class java.lang.Object

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

      • getParameters

        @Nonnull
        public static <T> java.util.List<ParameterResource> getParameters​(@Nonnull
                                                                          java.lang.reflect.Executable method,
                                                                          @Nullable
                                                                          java.util.List<T> parameterValues)
        Read all parameters from a method or a constructor and converts in into a list of ParameterResource. Respects ParameterKey annotation.
        Type Parameters:
        T - parameter values type
        Parameters:
        method - a method to read parameters
        parameterValues - a source of parameter values
        Returns:
        a list of parameter POJOs with fulfilled name and value.
      • toBoxedType

        public static java.lang.Class<?> toBoxedType​(@Nonnull
                                                     java.lang.Class<?> primitiveType)
        Converts primitive type to a corresponding boxed class, or returns the same instance if the input is not primitive.
        Parameters:
        primitiveType - a class which needs to be boxed
        Returns:
        boxed class type
      • getParameters

        @Nonnull
        public static <T> java.util.List<ParameterResource> getParameters​(@Nullable
                                                                          java.lang.String codeRef,
                                                                          @Nullable
                                                                          java.util.List<org.apache.commons.lang3.tuple.Pair<java.lang.String,​T>> parameters)
        Read all parameters from a method or a constructor and converts in into a list of ParameterResource. Respects ParameterKey annotation.
        Type Parameters:
        T - parameter values type
        Parameters:
        codeRef - a method reference to read parameters
        parameters - a source of parameter values and parameter names if not set by ParameterKey annotation
        Returns:
        a list of parameter POJOs with fulfilled name and value.
      • formatParametersAsTable

        @Nonnull
        public static java.lang.String formatParametersAsTable​(@Nonnull
                                                               java.util.List<ParameterResource> parameters)
        Format parameters as Markdown table.
        Parameters:
        parameters - list of parameters
        Returns:
        text representation of parameter table