public abstract class OptionsBase
extends java.lang.Object
X x = Options.getDefaults(X.class); x.host = "localhost"; x.port = 80;or from an array of command-line arguments:
OptionsParser parser = OptionsParser.newOptionsParser(X.class);
parser.parse("--host", "localhost", "--port", "80");
X x = parser.getOptions(X.class);
Subclasses of OptionsBase must be constructed reflectively,
i.e. using not new MyOptions, but one of the two methods above
instead. (Direct construction creates an empty instance, not containing
default values. This leads to surprising behavior and often
NullPointerExceptions, etc.)
| Modifier | Constructor and Description |
|---|---|
protected |
OptionsBase()
Subclasses must provide a default (no argument) constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.String,java.lang.Object> |
asMap()
Returns this options object in the form of a (new) mapping from option
names, including inherited ones, to option values.
|
java.lang.String |
cacheKey()
Returns a string that uniquely identifies the options.
|
boolean |
equals(java.lang.Object that) |
int |
hashCode() |
java.lang.String |
toString() |
protected OptionsBase()
public final java.util.Map<java.lang.String,java.lang.Object> asMap()
asMap.
Mutation of this map by the caller does not affect this options object.public final java.lang.String toString()
toString in class java.lang.Objectpublic final java.lang.String cacheKey()
public final boolean equals(java.lang.Object that)
equals in class java.lang.Objectpublic final int hashCode()
hashCode in class java.lang.Object