Class ArrayDirective<T>

java.lang.Object
org.refcodes.cli.ArrayOperand<T>
org.refcodes.cli.ArrayDirective<T>
Type Parameters:
T - the generic type
All Implemented Interfaces:
Cloneable, Comparable<Operand<?>>, Directive<T[]>, MatchCountAccessor, Operand<T[]>, OperationAccessor, ParsedArgsAccessor, Synopsisable, Term, ExceptionAccessor<ArgsSyntaxException>, VisibleAccessor, VisibleAccessor.VisibleBuilder<Term>, VisibleAccessor.VisibleMutator, VisibleAccessor.VisibleProperty, AliasAccessor, Clonable, DescriptionAccessor, Resetable, TypeAccessor<T[]>, ValueAccessor<T[]>, Diagnosable, Schemable<DiagnosticOptions>

public class ArrayDirective<T> extends ArrayOperand<T> implements Directive<T[]>
Creates an array representation facade for the encapsulated Directive. This way any Directive can also be used as an array Directive, e.g. it can be provided multiple times in the command line arguments.
  • Field Details

    • _description

      protected String _description
    • _exception

      protected ArgsSyntaxException _exception
    • _isVisible

      protected boolean _isVisible
  • Constructor Details

    • ArrayDirective

      public ArrayDirective(Directive<T> aDirective)
      Constructs the ArrayDirective by encapsulating the given Directive and providing its definition as array definition to the CLI.
      Parameters:
      aDirective - The Directive which's array counterpart is to be defined.
    • ArrayDirective

      public ArrayDirective(Directive<T> aDirective, int aLength)
      Constructs the ArrayDirective by encapsulating the given Directive and providing its definition as array definition to the CLI.
      Parameters:
      aDirective - The Directive which's array counterpart is to be defined.
      aLength - The number of array elements, or -1 if there is no limit.
    • ArrayDirective

      public ArrayDirective(Directive<T> aDirective, int aMinLength, int aMaxLength)
      Constructs the ArrayDirective by encapsulating the given Directive and providing its definition as array definition to the CLI.
      Parameters:
      aDirective - The Directive which's array counterpart is to be defined.
      aMinLength - The minimum number of array elements, or -1 if there is no limit.
      aMaxLength - The maximum number of array elements, or -1 if there is no limit.
  • Method Details

    • getOperation

      public String getOperation()
      Returns the operation assigned to the Directive instance.
      Specified by:
      getOperation in interface Directive<T>
      Specified by:
      getOperation in interface OperationAccessor
      Returns:
      The operation's String.
    • toSyntax

      public String toSyntax(CliContext aCliCtx)
      Creates a syntax including its arguments.

      A specification differs from a syntax in that the specification provides the full definition not omitting any choices whereas the syntax only provides a syntactically correct variant. For example, having an option with a short option and a long option, the specification will show the short option and the long option whereas the syntax will only show either the short option or, if no short option is set, the long option.

      Specified by:
      toSyntax in interface Directive<T>
      Specified by:
      toSyntax in interface Operand<T>
      Specified by:
      toSyntax in interface Term
      Overrides:
      toSyntax in class ArrayOperand<T>
      Parameters:
      aCliCtx - The CLI context controlling notation and formatting
      Returns:
      The human readable command line syntax
    • getException

      public ArgsSyntaxException getException()
      Retrieves the ArgsSyntaxException exception in case invoking Term.parseArgs(String[], CliContext) failed. The exception (and the according suppressed ones alongside the causes) does not necessarily have been thrown by the Term.parseArgs(String[], CliContext) method depending on the semantics of the Term handing the exception (the AnyCondition provides any exceptions it caught even though it did not throw them as of its semantics).
      Specified by:
      getException in interface ExceptionAccessor<ArgsSyntaxException>
      Specified by:
      getException in interface Term
      Returns:
      The ArgsSyntaxException exception occurring while parsing the arguments.
    • setVisible

      public void setVisible(boolean isVisible)

      Visibility in this context means displaying or hiding this Term's existence to the user (defaults to true).

      Specified by:
      setVisible in interface Term
      Specified by:
      setVisible in interface VisibleAccessor.VisibleMutator
    • isVisible

      public boolean isVisible()

      Visibility in this context means displaying or hiding this Term's existence to the user (defaults to true).

      Specified by:
      isVisible in interface Term
      Specified by:
      isVisible in interface VisibleAccessor
    • toArgsDiff

      protected static String[] toArgsDiff(String[] aArgs, List<? extends Operand<?>> aArgsSubset)
      Creates the difference between the provided set and the provided Lists therein found argument arrays subset (as of Operand.getParsedArgs()).
      Parameters:
      aArgs - The set to be used for the diff operation.
      aArgsSubset - The subset to be used for the diff operation being the lists containing the Operand instances whose command line arguments are to be diffed.
      Returns:
      The difference between the set and the subset.
    • toArgsDiff

      protected static String[] toArgsDiff(String[] aArgs, Operand<?>[] aArgsSubset)
      Creates the difference between the provided set and the provided Lists therein found argument arrays subset (as of Operand.getParsedArgs()).
      Parameters:
      aArgs - The set to be used for the diff operation.
      aArgsSubset - The subset to be used for the diff operation being the lists containing the Operand instances whose command line arguments are to be diffed.
      Returns:
      The difference between the set and the subset.
    • toArgsDiff

      protected static String[] toArgsDiff(String[] aArgs, String[] aArgsSubset)
      Creates the difference between the provided set and the provided subset.
      Parameters:
      aArgs - The set to be used for the diff operation.
      aArgsSubset - The subset to be used for the diff operation.
      Returns:
      The difference between the set and the subset.
    • toParsedArgs

      protected static String[] toParsedArgs(Operand<?>[]... aOperands)
      Takes all Operand instances found in the provided Lists and adds all therein found argument arrays (as of Operand.getParsedArgs()) to the result.
      Parameters:
      aOperands - The lists containing the Operand instances whose command line arguments are to be added to the result.
      Returns:
      All the command line arguments detected in the provided Operands Lists.