Enum Class ETriState

java.lang.Object
java.lang.Enum<ETriState>
com.helger.base.state.ETriState
All Implemented Interfaces:
IHasID<String>, ITriState, Serializable, Comparable<ETriState>, Constable

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
  • Enum Constant Details

    • TRUE

      public static final ETriState TRUE
    • FALSE

      public static final ETriState FALSE
    • UNDEFINED

      public static final ETriState UNDEFINED
  • Method Details

    • values

      public static ETriState[] 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

      public static ETriState valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • getID

      @Nonempty public @NonNull @Nonempty String getID()
      Get the unique ID of this object. If the type is String than the returned value must match an XML NMToken expression (so e.g. no ':' in the ID)!
      Specified by:
      getID in interface IHasID<String>
      Returns:
      The ID of this object. May not be null.
    • isTrue

      public boolean isTrue()
      Specified by:
      isTrue in interface ITriState
      Returns:
      true if the value is true.
    • isFalse

      public boolean isFalse()
      Specified by:
      isFalse in interface ITriState
      Returns:
      true if the value is false
    • isDefined

      public boolean isDefined()
      Specified by:
      isDefined in interface ITriState
      Returns:
      true if the value is not undefined (if it is either true or false)
    • getAsBooleanValue

      public boolean getAsBooleanValue()
      Convert the tri state value into a boolean value. If it is undefined, an IllegalStateException is thrown.
      Specified by:
      getAsBooleanValue in interface ITriState
      Returns:
      true if ITriState.isTrue() is true, false if ITriState.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:
      getAsBooleanValue in interface ITriState
      Parameters:
      bUndefinedValue - The boolean representation of undefined.
      Returns:
      true if ITriState.isTrue() is true, false if ITriState.isFalse() is true, or otherwise the passed parameter!
      See Also:
    • getAsBooleanObj

      public @Nullable Boolean getAsBooleanObj()
      Convert the tri state value into a Boolean value, depending on what "undefined" means.
      Specified by:
      getAsBooleanObj in interface ITriState
      Returns:
      Boolean.TRUE if ITriState.isTrue() is true, Boolean.FALSE if ITriState.isFalse() is true, or null!
    • getAsBooleanObj

      public @Nullable Boolean getAsBooleanObj(@Nullable Boolean aUndefinedValue)
      Convert the tri state value into a Boolean value, depending on what "undefined" means.
      Specified by:
      getAsBooleanObj in interface ITriState
      Parameters:
      aUndefinedValue - The Boolean representation of undefined.
      Returns:
      Boolean.TRUE if ITriState.isTrue() is true, Boolean.FALSE if ITriState.isFalse() is true, or otherwise the passed parameter!
    • valueOf

      public static @NonNull ETriState valueOf(boolean bValue)
      Convert a boolean value to the corresponding ETriState enum value.
      Parameters:
      bValue - true for TRUE, false for FALSE.
      Returns:
      Never null.
    • valueOf

      public static @NonNull ETriState valueOf(@Nullable Boolean aValue)
      Convert a Boolean value to the corresponding ETriState enum value.
      Parameters:
      aValue - The Boolean value. May be null for UNDEFINED.
      Returns:
      Never null.
    • valueOf

      public static @NonNull ETriState valueOf(@NonNull ITriState aTriState)
      Convert an ITriState to the corresponding ETriState enum value.
      Parameters:
      aTriState - The tri state to convert. May not be null.
      Returns:
      Never null.
    • getFromIDOrNull

      public static @Nullable ETriState getFromIDOrNull(@Nullable String sID)
      Get the ETriState enum value matching the provided ID.
      Parameters:
      sID - The ID to search. May be null.
      Returns:
      null if no matching enum value was found.
    • getFromIDOrUndefined

      public static @NonNull ETriState getFromIDOrUndefined(@Nullable String sID)
      Get the ETriState enum value matching the provided ID, defaulting to UNDEFINED.
      Parameters:
      sID - The ID to search. May be null.
      Returns:
      Never null.
    • getFromIDOrDefault

      public static @Nullable ETriState getFromIDOrDefault(@Nullable String sID, @Nullable ETriState eDefault)
      Get the ETriState enum value matching the provided ID, with a custom default.
      Parameters:
      sID - The ID to search. May be null.
      eDefault - The default value to return if no match is found. May be null.
      Returns:
      The matching enum value or the provided default.