Package org.refcodes.console
Interface Operand<T>
-
- Type Parameters:
T
- the generic type
- All Superinterfaces:
org.refcodes.mixin.AliasAccessor
,ArgsAccessor
,java.lang.Comparable<Operand<?>>
,org.refcodes.mixin.DescriptionAccessor
,org.refcodes.component.Resetable
,Syntaxable
,SyntaxUsage
,org.refcodes.mixin.TypeAccessor<T>
,org.refcodes.mixin.ValueAccessor<T>
- All Known Implementing Classes:
AbstractOperand
,AbstractOption
,EnumOptionImpl
,FlagImpl
,ForceFlagImpl
,HelpFlagImpl
,IntegerOptionImpl
,QuietFlagImpl
,StringOperandImpl
,StringOptionImpl
,SysInfoFlagImpl
,VerboseFlagImpl
public interface Operand<T> extends org.refcodes.mixin.ValueAccessor<T>, org.refcodes.mixin.DescriptionAccessor, org.refcodes.mixin.TypeAccessor<T>, Syntaxable, ArgsAccessor, java.lang.Comparable<Operand<?>>, org.refcodes.mixin.AliasAccessor
AnOperand
represents a value parsed from command line arguments. In comparison to anOption
anOperand
just represents a plain value without an identifier in front of it. AnOperand
has a state which changes with each invocation of theSyntaxable.parseArgs(String[])
method.It is recommended to put your
Operand
instance(s) at the end of your topCondition
to enforce it to be the lastSyntaxable
(s) when parsing the command line arguments - this makes sure that anyOption
s pick their option arguments so that theOperand
(s) will correctly be left over for parsing command line argument(s); theOperand
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.console.ArgsAccessor
ArgsAccessor.ArgsMutator, ArgsAccessor.ArgsProperty
-
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.mixin.TypeAccessor
org.refcodes.mixin.TypeAccessor.TypeMutator<T extends java.lang.Object>, org.refcodes.mixin.TypeAccessor.TypeProperty<T extends java.lang.Object>
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.ValueAccessor
org.refcodes.mixin.ValueAccessor.ValueBuilder<V extends java.lang.Object,B extends org.refcodes.mixin.ValueAccessor.ValueBuilder<V,B>>, org.refcodes.mixin.ValueAccessor.ValueMutator<V extends java.lang.Object>, org.refcodes.mixin.ValueAccessor.ValueProperty<V extends java.lang.Object>
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <V> V
get(java.lang.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.java.lang.String
getAlias()
java.lang.String[]
getArgs()
Retrieves the command line arguments from the args property.T
getValue()
default boolean
hasValue()
When being parsed via theSyntaxable.parseArgs(String[])
method, use this method to determine whether thegetValue()
method contains parsed value.-
Methods inherited from interface org.refcodes.console.Syntaxable
parseArgs, toState, toSyntax
-
Methods inherited from interface org.refcodes.console.SyntaxUsage
toUsage, toUsage
-
-
-
-
Method Detail
-
hasValue
default boolean hasValue()
When being parsed via theSyntaxable.parseArgs(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[])
method.
-
getArgs
java.lang.String[] getArgs()
Retrieves the command line arguments from the args property.- Specified by:
getArgs
in interfaceArgsAccessor
- Returns:
- The command line arguments stored by the args property.
-
getAlias
java.lang.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 syntaxString
viaSyntaxable.toSyntax(SyntaxNotation)
and the command line arguments detail description when creating a command line tool's help output.- Specified by:
getAlias
in interfaceorg.refcodes.mixin.AliasAccessor
- Returns:
- The name of the parameter, r.g the name of the operand or the name of the option argument.
-
get
default <V> V get(java.lang.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:
get
in 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.
-
-