org.elkoserver.foundation.json
Class OptBoolean

java.lang.Object
  extended by org.elkoserver.foundation.json.OptBoolean

public class OptBoolean
extends Object

An optional JSON message parameter of type boolean.


Field Summary
static OptBoolean theMissingValue
          Singleton instance of OptBoolean with the value not present.
 
Constructor Summary
OptBoolean(boolean value)
          Constructor (value present).
 
Method Summary
 boolean present()
          Test if this parameter's value was present.
 boolean value()
          Get the boolean value of the parameter.
 boolean value(boolean defaultValue)
          Get the boolean value of this parameter, or a default value if the value is absent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theMissingValue

public static final OptBoolean theMissingValue
Singleton instance of OptBoolean with the value not present.

Constructor Detail

OptBoolean

public OptBoolean(boolean value)
Constructor (value present).

Parameters:
value - The value of the parameter
Method Detail

value

public boolean value()
Get the boolean value of the parameter. It is an error if the value is absent.

Returns:
the (boolean) value.
Throws:
Error - if the value is not present.

value

public boolean value(boolean defaultValue)
Get the boolean value of this parameter, or a default value if the value is absent.

Parameters:
defaultValue - The default value for the parameter.
Returns:
the boolean value of this parameter if present, or the value of 'defaultValue' if not present.

present

public boolean present()
Test if this parameter's value was present.

Returns:
true if the parameter value was present, false if not.