Class ParameterType<T>

java.lang.Object
io.cucumber.cucumberexpressions.ParameterType<T>
All Implemented Interfaces:
Comparable<ParameterType<?>>

@API(status=STABLE) public final class ParameterType<T> extends Object implements Comparable<ParameterType<?>>
  • Field Details

    • ILLEGAL_PARAMETER_NAME_PATTERN

      private static final Pattern ILLEGAL_PARAMETER_NAME_PATTERN
    • UNESCAPE_PATTERN

      private static final Pattern UNESCAPE_PATTERN
    • name

      private final String name
    • type

      private final Type type
    • regexps

      private final List<String> regexps
    • preferForRegexpMatch

      private final boolean preferForRegexpMatch
    • useForSnippets

      private final boolean useForSnippets
    • transformer

      private final CaptureGroupTransformer<T> transformer
    • anonymous

      private final boolean anonymous
    • useRegexpMatchAsStrongTypeHint

      private final boolean useRegexpMatchAsStrongTypeHint
  • Constructor Details

  • Method Details

    • requireValidParameterTypeName

      static String requireValidParameterTypeName(String name)
    • isValidParameterTypeName

      static boolean isValidParameterTypeName(String name)
    • createAnonymousParameterType

      static ParameterType<Object> createAnonymousParameterType(String regexp)
    • fromEnum

      static <E extends Enum<E>> ParameterType<E> fromEnum(Class<E> enumClass)
    • getName

      public String getName()
      This is used in the type name in typed expressions
      Returns:
      human-readable type name
    • getType

      public Type getType()
      Returns the type of the parameter type - typically the type the transform transforms to. This can be used in conjunction with GeneratedExpression (snippets) to generate snippets for statically typed languages. Not used for anything else.
      Returns:
      the type of the parameter type
    • getRegexps

      public List<String> getRegexps()
    • preferForRegexpMatch

      public boolean preferForRegexpMatch()
      Indicates whether or not this is a preferential parameter type when matching text against a RegularExpression. In case there are multiple parameter types with a regexp identical to the capture group's regexp, a preferential parameter type will win. If there are more than 1 preferential ones, an error will be thrown.
      Returns:
      true if this is a preferential type
    • useForSnippets

      public boolean useForSnippets()
      Indicates whether this is a parameter type should be used for generating GeneratedExpressions from text. Typically, parameter types with greedy regexps should return false.
      Returns:
      true is this parameter type is used for expression generation
    • isAnonymous

      boolean isAnonymous()
    • useRegexpMatchAsStrongTypeHint

      public boolean useRegexpMatchAsStrongTypeHint()
      Indicates whether or not this parameter provides a strong type hint when considering a regular expression match. If so, the type hint provided by the method arguments will be ignored. If not, when both type hints are in agreement, this parameter types transformer will be used. Otherwise parameter transformation for a regular expression match will be handled by ParameterTypeRegistry.getDefaultParameterTransformer().
      Returns:
      true if this parameter type provides a type hint when considering a regular expression match
    • deAnonymize

      ParameterType<Object> deAnonymize(Type type, Transformer<Object> transformer)
    • transform

      @Nullable T transform(List<@Nullable String> groupValues)
    • compareTo

      public int compareTo(ParameterType<?> that)
      Specified by:
      compareTo in interface Comparable<T>
    • weight

      public int weight()