Package com.helger.base.state
Enum Class ETriState
- All Implemented Interfaces:
IHasID<String>,ITriState,Serializable,Comparable<ETriState>,Constable
Represents an object that has one of 3 different states compared to a boolean
that has only 2 different states.
- Author:
- Philip Helger
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescription@Nullable BooleanConvert the tri state value into aBooleanvalue, depending on what "undefined" means.@Nullable BooleangetAsBooleanObj(@Nullable Boolean aUndefinedValue) Convert the tri state value into aBooleanvalue, depending on what "undefined" means.booleanConvert the tri state value into a boolean value.booleangetAsBooleanValue(boolean bUndefinedValue) Convert the tri state value into a boolean value, depending on what "undefined" means.static @Nullable ETriStategetFromIDOrDefault(@Nullable String sID, @Nullable ETriState eDefault) Get theETriStateenum value matching the provided ID, with a custom default.static @Nullable ETriStategetFromIDOrNull(@Nullable String sID) Get theETriStateenum value matching the provided ID.static @NonNull ETriStategetFromIDOrUndefined(@Nullable String sID) @NonNull @Nonempty StringgetID()Get the unique ID of this object.booleanbooleanisFalse()booleanisTrue()static @NonNull ETriStatevalueOf(boolean bValue) Convert a boolean value to the correspondingETriStateenum value.static @NonNull ETriStatestatic @NonNull ETriStatestatic ETriStateReturns the enum constant of this class with the specified name.static ETriState[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOfMethods inherited from interface com.helger.base.state.ITriState
getAsBooleanObj, isUndefined
-
Enum Constant Details
-
TRUE
-
FALSE
-
UNDEFINED
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null
-
getID
Get the unique ID of this object. If the type isStringthan the returned value must match an XML NMToken expression (so e.g. no ':' in the ID)! -
isTrue
public boolean isTrue() -
isFalse
public boolean isFalse() -
isDefined
public boolean isDefined() -
getAsBooleanValue
public boolean getAsBooleanValue()Convert the tri state value into a boolean value. If it is undefined, anIllegalStateExceptionis thrown.- Specified by:
getAsBooleanValuein interfaceITriState- Returns:
trueifITriState.isTrue()is true,falseifITriState.isFalse()is true, or an exception otherwise!- See Also:
-
getAsBooleanValue
public boolean getAsBooleanValue(boolean bUndefinedValue) Convert the tri state value into a boolean value, depending on what "undefined" means.- Specified by:
getAsBooleanValuein interfaceITriState- Parameters:
bUndefinedValue- The boolean representation of undefined.- Returns:
trueifITriState.isTrue()is true,falseifITriState.isFalse()is true, or otherwise the passed parameter!- See Also:
-
getAsBooleanObj
Convert the tri state value into aBooleanvalue, depending on what "undefined" means.- Specified by:
getAsBooleanObjin interfaceITriState- Returns:
Boolean.TRUEifITriState.isTrue()istrue,Boolean.FALSEifITriState.isFalse()istrue, ornull!
-
getAsBooleanObj
Convert the tri state value into aBooleanvalue, depending on what "undefined" means.- Specified by:
getAsBooleanObjin interfaceITriState- Parameters:
aUndefinedValue- TheBooleanrepresentation of undefined.- Returns:
Boolean.TRUEifITriState.isTrue()is true,Boolean.FALSEifITriState.isFalse()is true, or otherwise the passed parameter!
-
valueOf
Convert a boolean value to the correspondingETriStateenum value. -
valueOf
- Parameters:
aValue- The Boolean value. May benullforUNDEFINED.- Returns:
- Never
null.
-
valueOf
- Parameters:
aTriState- The tri state to convert. May not benull.- Returns:
- Never
null.
-
getFromIDOrNull
Get theETriStateenum value matching the provided ID.- Parameters:
sID- The ID to search. May benull.- Returns:
nullif no matching enum value was found.
-
getFromIDOrUndefined
- Parameters:
sID- The ID to search. May benull.- Returns:
- Never
null.
-
getFromIDOrDefault
public static @Nullable ETriState getFromIDOrDefault(@Nullable String sID, @Nullable ETriState eDefault) Get theETriStateenum value matching the provided ID, with a custom default.- Parameters:
sID- The ID to search. May benull.eDefault- The default value to return if no match is found. May benull.- Returns:
- The matching enum value or the provided default.
-