Package openbook.tools
Class CommandProcessor.Option
- java.lang.Object
-
- openbook.tools.CommandProcessor.Option
-
- Enclosing class:
- CommandProcessor
public static class CommandProcessor.Option extends java.lang.ObjectA simple immutable object represents meta-data about a command option.- Author:
- Pinaki Poddar
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetDefaultValue()Gets the default value of this option.java.lang.StringgetDescription()java.lang.StringgetName()Gets the first alias as the name.static booleanisValidName(java.lang.String s)Affirms if the given string can be a valid option name.booleanmatch(java.lang.String name)Affirms if the given name any of the aliases.booleanrequiresInput()Affirms if this option requires a value.CommandProcessor.OptionsetDefault(java.lang.String v)Sets the default value for this option.CommandProcessor.OptionsetDescription(java.lang.String desc)java.lang.StringtoString()
-
-
-
Constructor Detail
-
Option
public Option(java.lang.String... aliases)
Create a command with given aliases. This option requires a value.- Parameters:
aliases- strings each must start with a dash (-).
-
Option
public Option(boolean requiresInput, java.lang.String... aliases)Create a option with given aliases.- Parameters:
requiresInput- does it require a value?aliases- strings each must start with a dash (-).
-
-
Method Detail
-
isValidName
public static boolean isValidName(java.lang.String s)
Affirms if the given string can be a valid option name. An option name always starts with dash and must be followed by at least one character.
-
getName
public java.lang.String getName()
Gets the first alias as the name.
-
setDefault
public CommandProcessor.Option setDefault(java.lang.String v)
Sets the default value for this option.- Parameters:
v- a default value.- Returns:
- this command itself.
- Throws:
java.lang.IllegalStateException- if this option does not require a value.
-
setDescription
public CommandProcessor.Option setDescription(java.lang.String desc)
-
getDescription
public java.lang.String getDescription()
-
match
public boolean match(java.lang.String name)
Affirms if the given name any of the aliases.
-
requiresInput
public boolean requiresInput()
Affirms if this option requires a value.
-
getDefaultValue
public java.lang.String getDefaultValue()
Gets the default value of this option.- Returns:
- the default value. null if no default value has been set.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-