edu.rice.cs.drjava.config
Class OptionParser<T>
java.lang.Object
edu.rice.cs.drjava.config.OptionParser<T>
- All Implemented Interfaces:
- ParseStrategy<T>
- Direct Known Subclasses:
- Option
public abstract class OptionParser<T>
- extends Object
- implements ParseStrategy<T>
The association of an OptionName with the ability to parse something to type T; the intended type
parameterization is covariant: if U extends T, then OptionParser extends OptionParser.
name
public final String name
- The logical name of this configurable option (i.e. "indent.size") public because it's final,
and a String is immutable.
defaultValue
protected final T defaultValue
OptionParser
public OptionParser(String name,
T def)
- Constructor that takes in a name
- Parameters:
name
- the name of this option (i.e. "indent.level");
getName
public String getName()
- Accessor for name option
- Returns:
- name of this option (i.e. "indent.level")
getDefault
public T getDefault()
- Returns:
- the default value
getDefaultString
public abstract String getDefaultString()
- Returns:
- the default value as a string
parse
public abstract T parse(String value)
- The ability to parse a string to an object of type T. All concrete versions of this class must override this
method to provide some sort of parser implementation.
- Specified by:
parse
in interface ParseStrategy<T>
- Parameters:
value
- a String to parse
- Returns:
- the statically-typed representation of the string value.
toString
public String toString()
- Returns a string representation of this OptionParser/Option suitable for debugging.
- Overrides:
toString
in class Object