- Type Parameters:
T- the generic type
- All Superinterfaces:
org.refcodes.mixin.AliasAccessor,ArgsAccessor,org.refcodes.mixin.Clonable,Cloneable,Comparable<Operand<?>>,org.refcodes.mixin.DescriptionAccessor,org.refcodes.mixin.Resetable,org.refcodes.mixin.Schemable<CliSchema>,Synopsisable,Syntaxable,org.refcodes.mixin.TypeAccessor<T>,org.refcodes.mixin.ValueAccessor<T>
- All Known Subinterfaces:
Option<T>
- All Known Implementing Classes:
AbstractOperand,AbstractOption,ArrayOperand,ArrayOption,CharOption,CleanFlag,ConfigOption,DaemonFlag,DebugFlag,DoubleOption,EnumOption,FileOption,Flag,FloatOption,ForceFlag,HelpFlag,InitFlag,IntOption,LongOption,NoneOperand,Operation,QuietFlag,StringOperand,StringOption,SysInfoFlag,VerboseFlag
public interface Operand<T>
extends org.refcodes.mixin.ValueAccessor<T>, org.refcodes.mixin.DescriptionAccessor, org.refcodes.mixin.TypeAccessor<T>, Syntaxable, ArgsAccessor, 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
Syntaxable.parseArgs(String[], String[]) method.
It is recommended to put your Operand instance(s) at the end of your
top ArgsSyntax to enforce it to be the last Syntaxable(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.AliasPropertyNested classes/interfaces inherited from interface org.refcodes.cli.ArgsAccessor
ArgsAccessor.ArgsMutator, ArgsAccessor.ArgsPropertyNested 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.DescriptionPropertyNested 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 TypeMethodDescriptiongetAlias()String[]getArgs()Retrieves the command line arguments from the args property.getValue()default booleanhasValue()When being parsed via theSyntaxable.parseArgs(String[], String[])method, use this method to determine whether thegetValue()method contains parsed value.default <V> VSearches 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
cloneMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface org.refcodes.mixin.DescriptionAccessor
getDescriptionMethods inherited from interface org.refcodes.mixin.Resetable
resetMethods inherited from interface org.refcodes.mixin.Schemable
toSchemaMethods inherited from interface org.refcodes.cli.Synopsisable
toSynopsis, toSynopsis, toSynopsis, toSynopsisMethods inherited from interface org.refcodes.cli.Syntaxable
parseArgs, parseArgs, toState, toSyntax, toSyntax, toSyntax, toSyntaxMethods inherited from interface org.refcodes.mixin.TypeAccessor
getTypeMethods inherited from interface org.refcodes.mixin.ValueAccessor
getValueOr
-
Method Details
-
getValue
T getValue()- Specified by:
getValuein interfaceorg.refcodes.mixin.ValueAccessor<T>
-
hasValue
default boolean hasValue()When being parsed via theSyntaxable.parseArgs(String[], String[])method, use this method to determine whether thegetValue()method contains parsed value.- Returns:
- The true in case there a value has been parsed via the
Syntaxable.parseArgs(String[], String[])method.
-
getArgs
String[] getArgs()Retrieves the command line arguments from the args property.- Specified by:
getArgsin interfaceArgsAccessor- Returns:
- The command line arguments stored by the args property.
-
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 syntaxStringviaSyntaxable.toSyntax(SyntaxNotation, String, String, String)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 anOperand's key/value-pair into a dictionary such as is done by theRuntimePropertiestype provided by therefcodes-properties-ext-runimeartifact!- Specified by:
getAliasin interfaceorg.refcodes.mixin.AliasAccessor- Returns:
- The name of the parameter, e.g the name of the operand or the name of the option argument.
-
toValue
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:
toValuein interfaceSyntaxable- 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.
-