Class RepeatingArgGroup

  • All Implemented Interfaces:
    DslArg

    public class RepeatingArgGroup
    extends java.lang.Object
    implements DslArg
    Define a group of arguments that can be repeated 0 or more times.

    The first argument in the group must be a RequiredArg and is used to identify the start of the group in arguments and when retrieving the groups from DslParams.valuesAsGroup(String). Other argument may follow the first argument in any order.

    Multiple RepeatingArgGroups can be used within the same DslParams but they cannot be nested.

    
     public void createUsers(String... args) {
         DslParams params = new DslParams(
             args,
             new RepeatingParamGroup(
                 new RequiredParam("user"),
                 new OptionalParam("password").setDefault("aPassword")
             ));
         for (RepeatingGroup user : params.valueAsGroup("user")) {
             driver.createUser(user.value("user"), user.value("password"));
         }
     }
     
    • Method Detail

      • getName

        public java.lang.String getName()
        Description copied from interface: DslArg
        Get the name of this argument.
        Specified by:
        getName in interface DslArg
        Returns:
        the argument name.
      • isRequired

        public boolean isRequired()
        Description copied from interface: DslArg
        Determine if a value is required for this argument.
        Specified by:
        isRequired in interface DslArg
        Returns:
        true if and only if this argument is required.
      • getDefaultValue

        public java.lang.String getDefaultValue()
        Description copied from interface: DslArg
        Get a default value for this argument.

        If the argument is required, this method will throw an IllegalArgumentException.

        Specified by:
        getDefaultValue in interface DslArg
        Returns:
        the default value for the argument
      • isAllowMultipleValues

        public boolean isAllowMultipleValues()
        Description copied from interface: DslArg
        Check whether this argument can take multiple values.
        Specified by:
        isAllowMultipleValues in interface DslArg
        Returns:
        true if and only if the argument takes multiple values.
      • getMultipleValueSeparator

        public java.lang.String getMultipleValueSeparator()
        Description copied from interface: DslArg
        Get the separator that can be used to separate multiple values.
        Specified by:
        getMultipleValueSeparator in interface DslArg
        Returns:
        the separator for splitting multiple values.
      • getAllowedValues

        public java.lang.String[] getAllowedValues()
        Description copied from interface: DslArg
        Get the specific values that this argument will accept.
        Specified by:
        getAllowedValues in interface DslArg
        Returns:
        the values allowed by this argument, or null if all values are allowed