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.schema.Schemable, Synopsisable, Term, org.refcodes.mixin.TypeAccessor<T>, org.refcodes.mixin.ValueAccessor<T>, org.refcodes.graphical.VisibleAccessor, org.refcodes.graphical.VisibleAccessor.VisibleBuilder<Term>, org.refcodes.graphical.VisibleAccessor.VisibleMutator, org.refcodes.graphical.VisibleAccessor.VisibleProperty
All Known Subinterfaces:
Directive<T>, Option<T>, Property<T>
All Known Implementing Classes:
AbstractDirective, AbstractOperand, AbstractOption, AbstractProperty, ArrayDirective, ArrayOperand, ArrayOption, BooleanDirective, BooleanOption, BooleanProperty, CharDirective, CharOption, CharProperty, CleanFlag, ConfigOption, ConfigProperty, DaemonFlag, DebugFlag, DoubleDirective, DoubleOption, DoubleProperty, EnumDirective, EnumOption, EnumProperty, FileDirective, FileOption, FileProperty, Flag, FloatDirective, FloatOption, FloatProperty, ForceFlag, HelpFlag, InitFlag, IntDirective, IntOption, IntProperty, LongDirective, LongOption, LongProperty, NoneOperand, Operation, QuietFlag, StringDirective, 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,B extends org.refcodes.mixin.TypeAccessor.TypeBuilder<T,B>>, org.refcodes.mixin.TypeAccessor.TypeMutator<T>, org.refcodes.mixin.TypeAccessor.TypeProperty<T>

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

    org.refcodes.mixin.ValueAccessor.ValueBuilder<V,B extends org.refcodes.mixin.ValueAccessor.ValueBuilder<V,B>>, org.refcodes.mixin.ValueAccessor.ValueMutator<V>, org.refcodes.mixin.ValueAccessor.ValueProperty<V>

    Nested classes/interfaces inherited from interface org.refcodes.graphical.VisibleAccessor

    org.refcodes.graphical.VisibleAccessor.VisibleBuilder<B extends org.refcodes.graphical.VisibleAccessor.VisibleBuilder<B>>, org.refcodes.graphical.VisibleAccessor.VisibleMutator, org.refcodes.graphical.VisibleAccessor.VisibleProperty
  • 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[]
    Produces the keywords (short and/or long options, operations, commands, whatever) with the according prefix (if any) to be considered when overall parsing the command line arguments.
    default String
    Creates a specification including its arguments.
    default String
    toSpec(String aArgumentEscCode, String aKeywordEscCode, String aResetEscCode)
    Creates a specification including its arguments.
    default String
    toSpec(CliContext aCliCtx)
    Creates a specification including its arguments.
    default String
    toSpec(SyntaxNotation aSyntaxNotation)
    Creates a specification including its arguments.
    default String
    toSpec(SyntaxNotation aSyntaxNotation, String aOptEscCode, String aParamEscCode, String aResetEscCode)
    Creates a specification including its arguments.
    default String
    Creates a syntax including its arguments.
    default String
    Creates a plain usage specification without any escape codes, helpful e.g. in human readable messages.
    default String
    Creates a plain usage specification without any escape codes, helpful e.g. in human readable messages.
    default <V> V
    toValue(String aAlias)
    Retrieves the value associated with the given alias after parsing.

    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.schema.Schemable

    toSchema

    Methods inherited from interface org.refcodes.cli.Synopsisable

    toSynopsis, toSynopsis, toSynopsis, toSynopsis

    Methods inherited from interface org.refcodes.mixin.TypeAccessor

    getType

    Methods inherited from interface org.refcodes.mixin.ValueAccessor

    getValueOr

    Methods inherited from interface org.refcodes.graphical.VisibleAccessor.VisibleBuilder

    withHide, withShow, withVisible

    Methods inherited from interface org.refcodes.graphical.VisibleAccessor.VisibleMutator

    hide, show

    Methods inherited from interface org.refcodes.graphical.VisibleAccessor.VisibleProperty

    letVisible
  • 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 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.
      Specified by:
      hasValue in interface org.refcodes.mixin.ValueAccessor<T>
      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.
    • toValue

      default <V> V toValue(String aAlias)
      Retrieves the value associated with the given alias after parsing.

      The syntax tree is searched for a Term that has produced a value for the specified alias.

      Specified by:
      toValue in interface Term
      Type Parameters:
      V - The expected value type
      Parameters:
      aAlias - The alias to resolve
      Returns:
      The resolved value or null if not set
    • toUsage

      default String toUsage()
      Creates a plain usage specification without any escape codes, helpful e.g. in human readable messages.
      Returns:
      The according usage text.
    • toUsage

      default String toUsage(CliContext aCliCtx)
      Creates a plain usage specification without any escape codes, helpful e.g. in human readable messages.
      Parameters:
      aCliCtx - The CliContext to use when creating a beautiful usage text.
      Returns:
      The according usage text.
    • toSpec

      default String toSpec()
      Creates a specification including its arguments.

      Note: 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.

      Returns:
      The according specification text.
    • toSpec

      default String toSpec(String aArgumentEscCode, String aKeywordEscCode, String aResetEscCode)
      Creates a specification 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.

      Note: This method uses the SyntaxNotation.LOGICAL be default!

      Parameters:
      aArgumentEscCode - The escape code to be used when processing an option, e.g. this can be an ANSI Escape-Code to highlight the option.
      aKeywordEscCode - The escape code to be used when processing a keyword, e.g. this can be an ANSI Escape-Code to highlight the option and/or parameters.
      aResetEscCode - The escape code to close (reset) any Escape-Code being set before.
      Returns:
      The according specification text.
    • toSpec

      default String toSpec(SyntaxNotation aSyntaxNotation)
      Creates a specification 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.

      Note: This method uses the default escape codes for syntax highlighting!

      Parameters:
      aSyntaxNotation - The syntax notation used for generating the command line arguments syntax.
      Returns:
      The according specification text.
    • toSpec

      default String toSpec(SyntaxNotation aSyntaxNotation, String aOptEscCode, String aParamEscCode, String aResetEscCode)
      Creates a specification 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.

      Parameters:
      aSyntaxNotation - The syntax notation used for generating the command line arguments syntax.
      aOptEscCode - The escape code to be used when processing an option, e.g. this can be an ANSI Escape-Code to highlight the option.
      aParamEscCode - The escape code to be used when processing a keyword, e.g. this can be an ANSI Escape-Code to highlight the option and/or parameters.
      aResetEscCode - The escape code to close (reset) any Escape-Code being set before.
      Returns:
      The according specification text.
    • toSpec

      default String toSpec(CliContext aCliCtx)
      Creates a specification 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.

      Parameters:
      aCliCtx - The CliContext to use when creating a beautiful specification text.
      Returns:
      The according specification text.
    • toSyntax

      default 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 Term
      Parameters:
      aCliCtx - The CLI context controlling notation and formatting
      Returns:
      The human readable command line syntax
    • toKeywords

      default String[] toKeywords(CliContext aCliCtx)
      Produces the keywords (short and/or long options, operations, commands, whatever) with the according prefix (if any) to be considered when overall parsing the command line arguments.
      Parameters:
      aCliCtx - The CliContext to use when assembling the keywords.
      Returns:
      The keywords with the according prefix.