|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.headius.options.Option<T>
T - the type of value associated with the optionpublic abstract class Option<T>
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.
StringOption,
IntegerOption,
BooleanOption,
EnuerationOption,
string(java.lang.String, java.lang.String, java.lang.Enum, java.lang.String),
integer(java.lang.String, java.lang.String, java.lang.Enum, java.lang.String),
bool(java.lang.String, java.lang.String, java.lang.Enum, java.lang.String),
enumeration(java.lang.String, java.lang.String, java.lang.Enum, java.lang.Class, java.lang.String) | Field Summary | |
|---|---|
protected T |
defval
|
protected Class<T> |
type
|
| Constructor Summary | |
|---|---|
Option(String longName,
Class<T> type,
Enum category,
T[] options,
T defval,
String description)
Create a new option with the given values. |
|
Option(String prefix,
String shortName,
Class<T> type,
Enum category,
T[] options,
T defval,
String description)
Create a new option with the given values. |
|
| Method Summary | ||
|---|---|---|
static Option<Boolean> |
bool(String longName,
Enum category,
Boolean defval,
String description)
Create a new Boolean option with the given configuration. |
|
static Option<Boolean> |
bool(String longName,
Enum category,
String description)
Create a new Boolean option with the given configuration. |
|
static Option<Boolean> |
bool(String prefix,
String name,
Enum category,
Boolean defval,
String description)
Create a new Boolean option with the given configuration. |
|
static Option<Boolean> |
bool(String prefix,
String name,
Enum category,
String description)
Create a new Boolean option with the given configuration. |
|
T |
defaultValue()
The default value for the option, or null if no default is provided. |
|
String |
description()
The long description of the property, as for documentation and configuration file templates. |
|
String |
displayName()
The display name of the option's property, either the short name or the full name. |
|
static
|
enumeration(String longName,
Enum category,
Class<T> enumClass,
String description)
Create a new Enumeration-based option with the given configuration. |
|
static
|
enumeration(String longName,
Enum category,
T defval,
String description)
Create a new Enumeration-based option with the given configuration. |
|
static
|
enumeration(String prefix,
String name,
Enum category,
Class<T> enumClass,
String description)
Create a new Enumeration-based option with the given configuration. |
|
static
|
enumeration(String prefix,
String name,
Enum category,
T defval,
String description)
Create a new Enumeration-based option with the given configuration. |
|
void |
force(String value)
Force the property value to the given value for all future loads and reloads. |
|
static String |
formatOptions(Collection<Option> options)
Format the given options in a way suitable for use as a configuration file or documentation. |
|
static String |
formatOptions(Option... options)
Format the given options in a way suitable for use as a configuration file or documentation. |
|
static String |
formatValues(Collection<Option> options)
Format the given options to show their loaded values in the current JVM. |
|
static String |
formatValues(Option... options)
Format the given options to show their loaded values in the current JVM. |
|
static Option<Integer> |
integer(String longName,
Enum category,
Integer[] options,
Integer defval,
String description)
Create a new Integer option with the given configuration. |
|
static Option<Integer> |
integer(String longName,
Enum category,
Integer[] options,
String description)
Create a new Integer option with the given configuration. |
|
static Option<Integer> |
integer(String longName,
Enum category,
Integer defval,
String description)
Create a new Integer option with the given configuration. |
|
static Option<Integer> |
integer(String longName,
Enum category,
String description)
Create a new Integer option with the given configuration. |
|
static Option<Integer> |
integer(String prefix,
String name,
Enum category,
Integer[] options,
Integer defval,
String description)
Create a new Integer option with the given configuration. |
|
static Option<Integer> |
integer(String prefix,
String name,
Enum category,
Integer[] options,
String description)
Create a new Integer option with the given configuration. |
|
static Option<Integer> |
integer(String prefix,
String name,
Enum category,
Integer defval,
String description)
Create a new Integer option with the given configuration. |
|
static Option<Integer> |
integer(String prefix,
String name,
Enum category,
String description)
Create a new Integer option with the given configuration. |
|
boolean |
isSpecified()
Return true if the option's property was specified, false otherwise. |
|
T |
load()
Return the value of the option, loading if it has not been already. |
|
String |
loadProperty()
Load the option's property, as if by calling java.lang.System#getProperty |
|
T[] |
options()
The array of accepted values for the option, or null if any values are accepted. |
|
String |
prefix()
If the property has a prefix, return it. |
|
String |
propertyName()
Return the full property name for the option. |
|
T |
reload()
Force a load of the option's property and return the loaded value. |
|
protected abstract T |
reloadValue()
Perform the appropriate load and conversion for the option's property. |
|
String |
shortName()
If the option has a short name, return it. |
|
static Option<String> |
string(String longName,
Enum category,
String description)
Create a new String option with the given configuration. |
|
static Option<String> |
string(String longName,
Enum category,
String[] options,
String description)
Create a new String option with the given configuration. |
|
static Option<String> |
string(String longName,
Enum category,
String[] options,
String defval,
String description)
Create a new String option with the given configuration. |
|
static Option<String> |
string(String longName,
Enum category,
String defval,
String description)
Create a new String option with the given configuration. |
|
static Option<String> |
string(String prefix,
String name,
Enum category,
String description)
Create a new String option with the given configuration. |
|
static Option<String> |
string(String prefix,
String name,
Enum category,
String[] options,
String description)
Create a new String option with the given configuration. |
|
static Option<String> |
string(String prefix,
String name,
Enum category,
String[] options,
String defval,
String description)
Create a new String option with the given configuration. |
|
static Option<String> |
string(String prefix,
String name,
Enum category,
String defval,
String description)
Create a new String option with the given configuration. |
|
String |
toString()
|
|
Class<T> |
type()
The type returned for the option. |
|
void |
unforce()
Undoes any previous force, and goes back to an unloaded state. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected final Class<T> type
protected final T defval
| Constructor Detail |
|---|
public Option(String prefix,
String shortName,
Class<T> type,
Enum category,
T[] options,
T defval,
String description)
C - an enumeration typeprefix - 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
public Option(String longName,
Class<T> type,
Enum category,
T[] options,
T defval,
String description)
C - an enumeration typelongName - 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 Detail |
|---|
public static Option<String> string(String prefix,
String name,
Enum category,
String description)
public static Option<String> string(String longName,
Enum category,
String description)
public static Option<String> string(String prefix,
String name,
Enum category,
String defval,
String description)
public static Option<String> string(String longName,
Enum category,
String defval,
String description)
public static Option<String> string(String prefix,
String name,
Enum category,
String[] options,
String description)
public static Option<String> string(String longName,
Enum category,
String[] options,
String description)
public static Option<String> string(String prefix,
String name,
Enum category,
String[] options,
String defval,
String description)
public static Option<String> string(String longName,
Enum category,
String[] options,
String defval,
String description)
public static Option<Boolean> bool(String prefix,
String name,
Enum category,
String description)
public static Option<Boolean> bool(String longName,
Enum category,
String description)
public static Option<Boolean> bool(String prefix,
String name,
Enum category,
Boolean defval,
String description)
public static Option<Boolean> bool(String longName,
Enum category,
Boolean defval,
String description)
public static Option<Integer> integer(String prefix,
String name,
Enum category,
String description)
public static Option<Integer> integer(String prefix,
String name,
Enum category,
Integer[] options,
String description)
public static Option<Integer> integer(String longName,
Enum category,
String description)
public static Option<Integer> integer(String longName,
Enum category,
Integer[] options,
String description)
public static Option<Integer> integer(String prefix,
String name,
Enum category,
Integer defval,
String description)
public static Option<Integer> integer(String longName,
Enum category,
Integer defval,
String description)
public static Option<Integer> integer(String prefix,
String name,
Enum category,
Integer[] options,
Integer defval,
String description)
public static Option<Integer> integer(String longName,
Enum category,
Integer[] options,
Integer defval,
String description)
public static <T extends Enum<T>> Option<T> enumeration(String prefix,
String name,
Enum category,
Class<T> enumClass,
String description)
public static <T extends Enum<T>> Option<T> enumeration(String longName,
Enum category,
Class<T> enumClass,
String description)
public static <T extends Enum<T>> Option<T> enumeration(String prefix,
String name,
Enum category,
T defval,
String description)
public static <T extends Enum<T>> Option<T> enumeration(String longName,
Enum category,
T defval,
String description)
public static String formatValues(Option... options)
public static String formatValues(Collection<Option> options)
public static String formatOptions(Option... options)
public static String formatOptions(Collection<Option> options)
public String toString()
toString in class Objectpublic String loadProperty()
public boolean isSpecified()
public final T load()
public final T reload()
public void force(String value)
value - public void unforce()
protected abstract T reloadValue()
public String shortName()
public String propertyName()
public String prefix()
public String displayName()
public Class<T> type()
public T[] options()
public T defaultValue()
public String description()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||