Package adams.core
Enum TriState
- java.lang.Object
-
- java.lang.Enum<TriState>
-
- adams.core.TriState
-
- All Implemented Interfaces:
EnumWithCustomDisplay<TriState>
,EnumWithCustomParsing<TriState>
,Serializable
,Comparable<TriState>
public enum TriState extends Enum<TriState> implements EnumWithCustomDisplay<TriState>
Enum that enhances a boolean to have a third state: not set.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
matches(Boolean state)
TriState
parse(String s)
Parses the given string and returns the associated enum.Boolean
toBoolean()
Turns the state into a boolean object with not-set corresponding to null.String
toDisplay()
Returns the display string.String
toRaw()
Returns the raw enum string.String
toString()
Returns the display string.static String
toString(AbstractOption option, Object object)
Returns the enum as string.static TriState
valueOf(AbstractOption option, String str)
Returns an enum generated from the string.static TriState
valueOf(String name)
Returns the enum constant of this type with the specified name.static TriState[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static TriState[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (TriState c : TriState.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static TriState valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
toDisplay
public String toDisplay()
Returns the display string.- Specified by:
toDisplay
in interfaceEnumWithCustomDisplay<TriState>
- Returns:
- the display string
-
toRaw
public String toRaw()
Returns the raw enum string.- Specified by:
toRaw
in interfaceEnumWithCustomDisplay<TriState>
- Returns:
- the raw enum string
-
toString
public String toString()
Returns the display string.
-
matches
public boolean matches(Boolean state)
- Parameters:
state
- the state to compare with- Returns:
- true if "TRUE && true" or "FALSE && false" or "NOT_SET && null"
-
toBoolean
public Boolean toBoolean()
Turns the state into a boolean object with not-set corresponding to null.- Returns:
- the boolean object
-
parse
public TriState parse(String s)
Parses the given string and returns the associated enum.- Specified by:
parse
in interfaceEnumWithCustomParsing<TriState>
- Parameters:
s
- the string to parse- Returns:
- the enum or null if not found
-
toString
public static String toString(AbstractOption option, Object object)
Returns the enum as string.- Parameters:
option
- the current optionobject
- the enum object to convert- Returns:
- the generated string
-
valueOf
public static TriState valueOf(AbstractOption option, String str)
Returns an enum generated from the string.- Parameters:
option
- the current optionstr
- the string to convert to an enum- Returns:
- the generated enum or null in case of error
-
-