Class OrCondition

All Implemented Interfaces:
Condition, Constituent, Synopsisable, org.refcodes.mixin.DescriptionAccessor, org.refcodes.mixin.Resetable, org.refcodes.mixin.Schemable<CliSchema>

public class OrCondition extends AbstractCondition implements Condition
An OrCondition represents a list of Condition (Constituent) instances of which at least one must be parsed successfully when the Constituent s' Constituent.parseArgs(String[], String[], CliContext) methods are invoked. The command line arguments syntax { -a | -b | -c } specifies that at least "-a", "-b" or "-c" must be set. In case none is set , then the OrCondition will terminate the parseArgs(String[], String[], CliContext) method with an exception.
  • Field Details

    • _description

      protected String _description
  • Constructor Details

  • Method Details

    • parseArgs

      public List<? extends Operand<?>> parseArgs(String[] aArgs, String[] aOptions, CliContext aCliCtx) throws ArgsSyntaxException
      Parses the provided command line arguments and determines the according values by evaluating this Constituent instance or, in case of being a node in the syntax tree (such as a Condition, traversing the child Constituent instances' Constituent.parseArgs(String[], String[], CliContext) methods. In case of successfully parsing this Constituent and / or the child Constituent instances, the evaluated command line arguments are returned: Depending on the Constituent subclasses representing the evaluated command line arguments, instances of Flag classes, Option classes or Operand classes may be found in the result. In case of parsing failure, an according exception is thrown. ATTENTION: This method does not test for superfluous command line arguments being passed; e.g. command line arguments not being evaluated by any of the Constituent instance being traversed. This method is commonly used by a root Constituent's ArgsParser.evalArgs(String[]) method, which delegates to the Constituent.parseArgs(String[], String[], CliContext) method and after which it determines whether there are superfluous arguments to be taken care of (by throwing an according exception). Business logic therefore should invoke the root node's Constituent.parseArgs(String[], String[], CliContext) method as ignoring superfluous command line arguments will cause unexpected behavior from the point of view of the invoker.
      Specified by:
      parseArgs in interface Constituent
      Parameters:
      aArgs - The command line arguments to be parsed.
      aOptions - The list of options (short and as well as long) which are reserved and cannot be used as value.
      aCliCtx - the cli context
      Returns:
      The list of evaluated command line arguments being instances of the Operand interfaces or its sub-types.
      Throws:
      ArgsSyntaxException - thrown in case of a command line arguments mismatch regarding provided and expected args.
    • toSynopsis

      public String toSynopsis(CliContext aCliCtx)
      Returns the human readable (verbose) syntax of implementing class ATTENTION: As of different parenthesis settings for some notations regarding the root Constituent and the child Constituents, the method Constituent.toSyntax(CliContext) is called from inside a Constituent hierarchy. In case the syntax is to be retrieved from the root Constituent or an encapsulating and different type, then the applicable method to be called is Synopsisable.toSynopsis(SyntaxNotation), as for some notations it will for example not create the most outer braces.
      Specified by:
      toSynopsis in interface Constituent
      Specified by:
      toSynopsis in interface Synopsisable
      Parameters:
      aCliCtx - The CliContext for which the syntax is being generated.
      Returns:
      The human readable (verbose) command line arguments syntax.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractCondition
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface org.refcodes.mixin.DescriptionAccessor