Class Option<T>
java.lang.Object
com.headius.options.Option<T>
- Type Parameters:
T- the type of value associated with the option
- Direct Known Subclasses:
BooleanOption, EnumerationOption, IntegerOption, StringOption
Represents a single option, with a category, name, value type,
options, default value, and description.
This type should be subclassed for specific types of values.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreate a new Boolean option with the given configuration.Create a new Boolean option with the given configuration.Create a new Boolean option with the given configuration.Create a new Boolean option with the given configuration.The default value for the option, or null if no default is provided.The long description of the property, as for documentation and configuration file templates.The display name of the option's property, either the short name or the full name.private static StringencodeWhitespace(Object obj) enumeration(String longName, Enum category, Class<T> enumClass, String description) Create a new Enumeration-based option with the given configuration.enumeration(String longName, Enum category, T defval, String description) Create a new Enumeration-based option with the given configuration.Create a new Enumeration-based option with the given configuration.enumeration(String prefix, String name, Enum category, T defval, String description) Create a new Enumeration-based option with the given configuration.voidForce the property value to the given value for all future loads and reloads.static StringformatOptions(Option... options) Format the given options in a way suitable for use as a configuration file or documentation.static StringformatOptions(Collection<Option> options) Format the given options in a way suitable for use as a configuration file or documentation.static StringformatValues(Option... options) Format the given options to show their loaded values in the current JVM.static StringformatValues(Collection<Option> options) Format the given options to show their loaded values in the current JVM.Create a new Integer option with the given configuration.Create a new Integer option with the given configuration.Create a new Integer option with the given configuration.Create a new Integer option with the given configuration.integer(String prefix, String name, Enum category, Integer[] options, Integer defval, String description) Create a new Integer option with the given configuration.Create a new Integer option with the given configuration.Create a new Integer option with the given configuration.Create a new Integer option with the given configuration.booleanReturn true if the option's property was specified, false otherwise.final Tload()Return the value of the option, loading if it has not been already.Load the option's property, as if by calling java.lang.System#getPropertyT[]options()The array of accepted values for the option, or null if any values are accepted.prefix()If the property has a prefix, return it.Return the full property name for the option.final Treload()Force a load of the option's property and return the loaded value.protected abstract TPerform the appropriate load and conversion for the option's property.If the option has a short name, return it.Create a new String option with the given configuration.Create a new String option with the given configuration.Create a new String option with the given configuration.Create a new String option with the given configuration.Create a new String option with the given configuration.Create a new String option with the given configuration.string(String prefix, String name, Enum category, String[] options, String defval, String description) Create a new String option with the given configuration.Create a new String option with the given configuration.toString()type()The type returned for the option.voidunforce()Undoes any previous force, and goes back to an unloaded state.
-
Field Details
-
OptionComparator
-
category
-
prefix
-
shortName
-
longName
-
displayName
-
type
-
options
-
defval
-
description
-
forced
-
specified
private boolean specified -
value
-
loaded
private volatile boolean loaded
-
-
Constructor Details
-
Option
public Option(String prefix, String shortName, Class<T> type, Enum category, T[] options, T defval, String description) Create a new option with the given values.- Type Parameters:
C- an enumeration type- Parameters:
prefix- the prefix used for loading this option from propertiesshortName- the rest of the property nametype- the value type of the optioncategory- the category to which this option belongsoptions- a list of supported for the option, or null if the set is not applicabledefval- the default value for the optiondescription- a description for the option
-
Option
public Option(String longName, Class<T> type, Enum category, T[] options, T defval, String description) Create a new option with the given values.- Type Parameters:
C- an enumeration type- Parameters:
longName- the property nametype- the value type of the optioncategory- the category to which this option belongsoptions- a list of supported for the option, or null if the set is not applicabledefval- the default value for the optiondescription- a description for the option
-
-
Method Details
-
string
-
string
-
string
-
string
-
string
-
string
-
string
-
string
-
bool
-
bool
-
bool
-
bool
-
integer
-
integer
-
integer
-
integer
-
integer
-
integer
-
integer
-
integer
-
enumeration
-
enumeration
-
enumeration
-
enumeration
-
formatValues
-
formatValues
Format the given options to show their loaded values in the current JVM. -
formatOptions
-
formatOptions
Format the given options in a way suitable for use as a configuration file or documentation. -
encodeWhitespace
-
toString
-
loadProperty
Load the option's property, as if by calling java.lang.System#getProperty -
isSpecified
public boolean isSpecified()Return true if the option's property was specified, false otherwise. -
load
Return the value of the option, loading if it has not been already. -
reload
Force a load of the option's property and return the loaded value. -
force
Force the property value to the given value for all future loads and reloads.- Parameters:
value-
-
unforce
public void unforce()Undoes any previous force, and goes back to an unloaded state. -
reloadValue
Perform the appropriate load and conversion for the option's property. -
shortName
If the option has a short name, return it. Otherwise null. -
propertyName
Return the full property name for the option. -
prefix
If the property has a prefix, return it. Otherwise null. -
displayName
The display name of the option's property, either the short name or the full name. -
type
-
options
The array of accepted values for the option, or null if any values are accepted. -
defaultValue
The default value for the option, or null if no default is provided. -
description
The long description of the property, as for documentation and configuration file templates.
-