Package com.helger.commons.state
Enum ETriState
- java.lang.Object
-
- java.lang.Enum<ETriState>
-
- com.helger.commons.state.ETriState
-
- All Implemented Interfaces:
IHasID<String>,ITriState,Serializable,Comparable<ETriState>
public enum ETriState extends Enum<ETriState> implements IHasID<String>, ITriState
Represents an object that has one of 3 different states compared to a boolean that has only 2 different states.- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BooleangetAsBooleanObj()Convert the tri state value into aBooleanvalue, depending on what "undefined" means.BooleangetAsBooleanObj(Boolean aUndefinedValue)Convert the tri state value into aBooleanvalue, depending on what "undefined" means.booleangetAsBooleanValue()Convert 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 ETriStategetFromIDOrDefault(String sID, ETriState eDefault)static ETriStategetFromIDOrNull(String sID)static ETriStategetFromIDOrUndefined(String sID)StringgetID()Get the unique ID of this object.booleanisDefined()booleanisFalse()booleanisTrue()static ETriStatevalueOf(boolean bValue)Returns the enum constant of this type with the specified name.static ETriStatevalueOf(ITriState aTriState)Returns the enum constant of this type with the specified name.static ETriStatevalueOf(Boolean aValue)Returns the enum constant of this type with the specified name.static ETriStatevalueOf(String name)Returns the enum constant of this type with the specified name.static ETriState[]values()Returns an array containing the constants of this enum type, in the order they are declared.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Methods inherited from interface com.helger.commons.state.ITriState
getAsBooleanObj, isUndefined
-
-
-
-
Method Detail
-
values
public static ETriState[] 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 (ETriState c : ETriState.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ETriState 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
-
getID
@Nonnull @Nonempty public String getID()
Description copied from interface:IHasIDGet 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()
Description copied from interface:ITriStateConvert 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:
ITriState.getAsBooleanValue(boolean)
-
getAsBooleanValue
public boolean getAsBooleanValue(boolean bUndefinedValue)
Description copied from interface:ITriStateConvert 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:
ITriState.getAsBooleanValue()
-
getAsBooleanObj
@Nullable public Boolean getAsBooleanObj()
Description copied from interface:ITriStateConvert 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
@Nullable public Boolean getAsBooleanObj(@Nullable Boolean aUndefinedValue)
Description copied from interface:ITriStateConvert 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
@Nonnull public static ETriState valueOf(boolean bValue)
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:
bValue- 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
-
valueOf
@Nonnull public static ETriState valueOf(@Nullable Boolean aValue)
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:
aValue- 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
-
valueOf
@Nonnull public static ETriState valueOf(@Nonnull ITriState aTriState)
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:
aTriState- 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
-
-