public final enum

TriState

extends Enum<E extends Enum<E>>
java.lang.Object
   ↳ java.lang.Enum<E extends java.lang.Enum<E>>
     ↳ com.facebook.common.util.TriState

Class Overview

Generic tri-state enum for boolean values that can also be unset.

Summary

Enum Values
TriState  NO   
TriState  UNSET   
TriState  YES   
Public Methods
boolean asBoolean(boolean defaultValue)
Returns the boolean value that corresponds to this TriState, if appropriate.
boolean asBoolean()
Returns the boolean value that corresponds to this TriState, if appropriate.
Boolean asBooleanObject()
Returns the Boolean value that corresponds to this TriState, if appropriate.
static TriState fromDbValue(int value)
int getDbValue()
boolean isSet()
static TriState valueOf(String name)
static TriState valueOf(boolean bool)
Returns the value of the TriState enum that corresponds to the specified boolean.
static TriState valueOf(Boolean bool)
final static TriState[] values()
[Expand]
Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values

public static final TriState NO

public static final TriState UNSET

public static final TriState YES

Public Methods

public boolean asBoolean (boolean defaultValue)

Returns the boolean value that corresponds to this TriState, if appropriate.

Parameters
defaultValue default value to use if not set
Returns
  • true if this is YES or false if this is NO or defaultValue if this is UNSET.

public boolean asBoolean ()

Returns the boolean value that corresponds to this TriState, if appropriate.

Returns
  • true if this is YES or false if this is NO
Throws
IllegalStateException if this is UNSET.

public Boolean asBooleanObject ()

Returns the Boolean value that corresponds to this TriState, if appropriate.

Returns

public static TriState fromDbValue (int value)

public int getDbValue ()

public boolean isSet ()

Returns
  • whether this value is set; that is, whether it is YES or NO.

public static TriState valueOf (String name)

public static TriState valueOf (boolean bool)

Returns the value of the TriState enum that corresponds to the specified boolean.

This method deliberately declares boolean as its param type rather than Boolean because:

  1. Declaring Boolean would likely result in a bunch of unnecessary autoboxing.
  2. Anyone who finds himself using a Boolean instead of a boolean for its nullability should replace the Boolean with a TriState, anyway.

public static TriState valueOf (Boolean bool)

public static final TriState[] values ()