Interface Operand<T>

Type Parameters:
T - The generic type of the Operand's value.
All Superinterfaces:
org.refcodes.mixin.AliasAccessor, org.refcodes.mixin.Clonable, Cloneable, Comparable<Operand<?>>, org.refcodes.mixin.DescriptionAccessor, org.refcodes.exception.ExceptionAccessor<ArgsSyntaxException>, MatchCountAccessor, ParsedArgsAccessor, org.refcodes.mixin.Resetable, org.refcodes.mixin.Schemable, Synopsisable, Term, org.refcodes.mixin.TypeAccessor<T>, org.refcodes.mixin.ValueAccessor<T>
All Known Subinterfaces:
Option<T>, PropertyOption<T>
All Known Implementing Classes:
AbstractOperand, AbstractOption, AbstractPropertyOption, ArrayOperand, ArrayOption, BooleanOption, BooleanProperty, CharOption, CharProperty, CleanFlag, ConfigOption, ConfigProperty, DaemonFlag, DebugFlag, DoubleOption, DoubleProperty, EnumOption, EnumProperty, FileOption, FileProperty, Flag, FloatOption, FloatProperty, ForceFlag, HelpFlag, InitFlag, IntOption, IntProperty, LongOption, LongProperty, NoneOperand, Operation, QuietFlag, StringOperand, StringOption, StringProperty, SysInfoFlag, VerboseFlag

public interface Operand<T> extends Term, org.refcodes.mixin.ValueAccessor<T>, org.refcodes.mixin.TypeAccessor<T>, ParsedArgsAccessor, Comparable<Operand<?>>, org.refcodes.mixin.AliasAccessor, Cloneable, org.refcodes.mixin.Clonable
An Operand represents a value parsed from command line arguments. In comparison to an Option an Operand just represents a plain value without an identifier in front of it. An Operand has a state which changes with each invocation of the Term.parseArgs(String[], String[], CliContext) method.

It is recommended to put your Operand instance(s) at the end of your top Condition to enforce it to be the last Term(s) when parsing the command line arguments - this makes sure that any Options pick their option arguments so that the Operand(s) will correctly be left over for parsing command line argument(s); the Operand will not pick by mistake an option argument.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.refcodes.mixin.AliasAccessor

    org.refcodes.mixin.AliasAccessor.AliasBuilder<B extends org.refcodes.mixin.AliasAccessor.AliasBuilder<B>>, org.refcodes.mixin.AliasAccessor.AliasMutator, org.refcodes.mixin.AliasAccessor.AliasProperty

    Nested classes/interfaces inherited from interface org.refcodes.mixin.DescriptionAccessor

    org.refcodes.mixin.DescriptionAccessor.DescriptionBuilder<B extends org.refcodes.mixin.DescriptionAccessor.DescriptionBuilder<B>>, org.refcodes.mixin.DescriptionAccessor.DescriptionMutator, org.refcodes.mixin.DescriptionAccessor.DescriptionProperty

    Nested classes/interfaces inherited from interface org.refcodes.exception.ExceptionAccessor

    org.refcodes.exception.ExceptionAccessor.ExceptionBuilder<EXC extends Throwable,B extends org.refcodes.exception.ExceptionAccessor.ExceptionBuilder<EXC,B>>, org.refcodes.exception.ExceptionAccessor.ExceptionMutator<EXC extends Throwable>, org.refcodes.exception.ExceptionAccessor.ExceptionProperty<EXC extends Throwable>

    Nested classes/interfaces inherited from interface org.refcodes.cli.ParsedArgsAccessor

    ParsedArgsAccessor.ParsedArgsMutator, ParsedArgsAccessor.ParsedArgsProperty

    Nested classes/interfaces inherited from interface org.refcodes.mixin.TypeAccessor

    org.refcodes.mixin.TypeAccessor.TypeBuilder<T extends Object,B extends org.refcodes.mixin.TypeAccessor.TypeBuilder<T,B>>, org.refcodes.mixin.TypeAccessor.TypeMutator<T extends Object>, org.refcodes.mixin.TypeAccessor.TypeProperty<T extends Object>

    Nested classes/interfaces inherited from interface org.refcodes.mixin.ValueAccessor

    org.refcodes.mixin.ValueAccessor.ValueBuilder<V extends Object,B extends org.refcodes.mixin.ValueAccessor.ValueBuilder<V,B>>, org.refcodes.mixin.ValueAccessor.ValueMutator<V extends Object>, org.refcodes.mixin.ValueAccessor.ValueProperty<V extends Object>
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves the name (alias) of the parameter value which can be the name of the operand (Operand) or the option argument (Option), depending on the sub-type inheriting from this interface.
    Retrieves the (command line) args which represent this Operand after being "parsed" (provided with command line args).
    default boolean
    When being parsed via the Term.parseArgs(String[], String[], CliContext) method, use this method to determine whether the getValue() method contains parsed value.
    default String
    Creates a specification for this Operand, helpful e.g. in human readable messages.
    default String
    toUsage(CliContext aCliContext)
    Creates a specification for this Operand, helpful e.g. in human readable messages.
    default <V> V
    toValue(String aAlias)
    Searches for a value being set for the given for given alias in the syntax tree parsing the command line arguments; if a node in the syntax tree has a value for the given alias, then this value is returned.

    Methods inherited from interface org.refcodes.mixin.Clonable

    clone

    Methods inherited from interface java.lang.Comparable

    compareTo

    Methods inherited from interface org.refcodes.mixin.DescriptionAccessor

    getDescription

    Methods inherited from interface org.refcodes.mixin.Resetable

    reset

    Methods inherited from interface org.refcodes.cli.Synopsisable

    toSynopsis, toSynopsis, toSynopsis, toSynopsis

    Methods inherited from interface org.refcodes.cli.Term

    getException, getMatchCount, parseArgs, parseArgs, toSchema, toSynopsis, toSyntax, toSyntax, toSyntax, toSyntax, toSyntax

    Methods inherited from interface org.refcodes.mixin.TypeAccessor

    getType

    Methods inherited from interface org.refcodes.mixin.ValueAccessor

    getValueOr
  • Method Details

    • getAlias

      String getAlias()
      Retrieves the name (alias) of the parameter value which can be the name of the operand (Operand) or the option argument (Option), depending on the sub-type inheriting from this interface. The parameter name is merely used for constructing the command line arguments syntax String via Term.toSyntax(CliContext) and the command line arguments detail description when creating a command line tool's help output. Attention: The alias can also be used as a key when putting an Operand's key/value-pair into a dictionary such as is done by the ApplicationProperties type provided by the refcodes-properties-ext-runime artifact!
      Specified by:
      getAlias in interface org.refcodes.mixin.AliasAccessor
      Returns:
      The name of the parameter, e.g the name of the operand or the name of the option argument.
    • getValue

      T getValue()
      Specified by:
      getValue in interface org.refcodes.mixin.ValueAccessor<T>
    • hasValue

      default boolean hasValue()
      When being parsed via the Term.parseArgs(String[], String[], CliContext) method, use this method to determine whether the getValue() method contains parsed value.
      Returns:
      The true in case there a value has been parsed via the Term.parseArgs(String[], String[], CliContext) method.
    • getParsedArgs

      String[] getParsedArgs()
      Retrieves the (command line) args which represent this Operand after being "parsed" (provided with command line args).
      Specified by:
      getParsedArgs in interface ParsedArgsAccessor
      Returns:
      The according args from the command line args.
    • toUsage

      default String toUsage()
      Creates a specification for this Operand, helpful e.g. in human readable messages. The specification is created using a plain (default) CliContext instance, for fine grained control on the specification, use a dedicated CliContext instance and invoke toUsage(CliContext).
      Returns:
      The according specification.
    • toUsage

      default String toUsage(CliContext aCliContext)
      Creates a specification for this Operand, helpful e.g. in human readable messages.
      Parameters:
      aCliContext - The CliContext to use when creating a beautiful specification.
      Returns:
      The according specification.
    • toValue

      default <V> V toValue(String aAlias)
      Searches for a value being set for the given for given alias in the syntax tree parsing the command line arguments; if a node in the syntax tree has a value for the given alias, then this value is returned.
      Specified by:
      toValue in interface Term
      Type Parameters:
      V - The type of the value being expected.
      Parameters:
      aAlias - The alias for which to seek for a value being set.
      Returns:
      The according value or null if none has been set for the given alias.