public class DefaultBooleanToNumberConverter extends AbstractReverseCachedDataConverter<java.lang.Boolean,java.lang.Number,DefaultBooleanToNumberConverter.Reverse>
Boolean
to a Number
by using predefined values
for true, false, and (optionally) null.Modifier and Type | Class and Description |
---|---|
class |
DefaultBooleanToNumberConverter.Reverse
The reverse converter for the
DefaultBooleanToNumberConverter . |
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_FALSE_VALUE
The default value for false is -1.0.
|
static double |
DEFAULT_NULL_VALUE
The default value for null is 0.0.
|
static double |
DEFAULT_TRUE_VALUE
The default value for true is 1.0.
|
protected java.lang.Number |
falseValue
The number to use to represent a false value.
|
protected java.lang.Number |
nullValue
The number to use to represent a null value.
|
protected java.lang.Number |
trueValue
The number to use to represent a true value.
|
reverse
Constructor and Description |
---|
DefaultBooleanToNumberConverter()
Creates a new
DefaultBooleanToNumberConverter with default values. |
DefaultBooleanToNumberConverter(java.lang.Number trueValue,
java.lang.Number falseValue,
java.lang.Number nullValue)
Creates a new
DefaultBooleanToNumberConverter . |
Modifier and Type | Method and Description |
---|---|
java.lang.Boolean |
convertToBoolean(java.lang.Number input)
Converts the given number to a boolean value by determining if it is
closer to the number representing true or the number representing false.
|
java.lang.Number |
convertToNumber(java.lang.Boolean input)
Converts the given boolean to a number using the
|
protected DefaultBooleanToNumberConverter.Reverse |
createReverse()
Creates a new reverse converter.
|
java.lang.Number |
evaluate(java.lang.Boolean input)
Converts an input boolean to a number.
|
java.lang.Number |
getFalseValue()
Gets the number that represents a falue value.
|
java.lang.Number |
getNullValue()
Gets the number that represents a null value.
|
java.lang.Number |
getTrueValue()
Gets the number that represents a true value.
|
void |
setFalseValue(java.lang.Number falseValue)
Sets the number that represents a falue value.
|
void |
setNullValue(java.lang.Number nullValue)
Sets the number that represents a null value.
|
void |
setTrueValue(java.lang.Number trueValue)
Sets the number that represents a true value.
|
reverse
clone
public static final double DEFAULT_TRUE_VALUE
public static final double DEFAULT_FALSE_VALUE
public static final double DEFAULT_NULL_VALUE
protected java.lang.Number trueValue
protected java.lang.Number falseValue
protected java.lang.Number nullValue
public DefaultBooleanToNumberConverter()
DefaultBooleanToNumberConverter
with default values.public DefaultBooleanToNumberConverter(java.lang.Number trueValue, java.lang.Number falseValue, java.lang.Number nullValue)
DefaultBooleanToNumberConverter
.trueValue
- The number to use for true.falseValue
- The number to use for false.nullValue
- The number to use for null.public java.lang.Number evaluate(java.lang.Boolean input)
input
- The input value to convert.public java.lang.Number convertToNumber(java.lang.Boolean input)
input
- The input boolean to convert to a number.public java.lang.Boolean convertToBoolean(java.lang.Number input)
input
- The input number to convert to a boolean.protected DefaultBooleanToNumberConverter.Reverse createReverse()
AbstractReverseCachedDataConverter
createReverse
in class AbstractReverseCachedDataConverter<java.lang.Boolean,java.lang.Number,DefaultBooleanToNumberConverter.Reverse>
public java.lang.Number getTrueValue()
public void setTrueValue(java.lang.Number trueValue)
trueValue
- The number that represents a true value.public java.lang.Number getFalseValue()
public void setFalseValue(java.lang.Number falseValue)
falseValue
- The number that represents a false value.public java.lang.Number getNullValue()
public void setNullValue(java.lang.Number nullValue)
nullValue
- The number that represents a null value.