Class BooleanValue
java.lang.Object
com.aquima.interactions.foundation.types.AbstractValue
com.aquima.interactions.foundation.types.BooleanValue
- All Implemented Interfaces:
IConvertable
,IPrimitiveValue
,ISingleValue
,IValue
,Serializable
,Comparable<Object>
- Direct Known Subclasses:
AttributeBooleanValue
This class does not extend the AbstractValue class, as the auto-conversion methods to ranges and lists are useless
(and even unwanted) for the boolean type.
- Since:
- 5.0
- Author:
- O. Kerpershoek
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BooleanValue
This member defines the FALSE value for the boolean type.static final BooleanValue
This member defines the TRUE value for the boolean type.static final BooleanValue
This member defines the UNKNOWN value for the boolean type. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructs an unknown boolean value.BooleanValue
(boolean booleanValue) Constructs a boolean value from a boolean primitive.BooleanValue
(IMultilingualText displayValue, boolean booleanValue) Constructs a boolean value with a display text.BooleanValue
(BooleanValue other) Copy constructor.BooleanValue
(String typeName, IMultilingualText displayValue, boolean booleanValue) Constructs a boolean value with a type name and display text. -
Method Summary
Modifier and TypeMethodDescriptionboolean
This method converts the internal value to a boolean primitive.protected int
compareSimple
(Object obj) int
boolean
This method returns a boolean indicating if the object passed to this method is entirely part of this value.This method converts the internal value to a date object.double
This method converts the internal value to a double primitive.This method returns a deep copy of the value.boolean
forType
(String typeName, IMultilingualText displayValue) This method adds the type and display information to the value, and returns the value with this added information.This method returns the data type of the value.getValue()
This method returns the internal object of this instance without any conversion.int
hashCode()
int
This method converts the internal value to an integer primitive.boolean
This method returns a boolean indicating if the value is unknown.long
This method converts the internal value to a long primitive.static boolean
parseBoolean
(Object obj) This method will convert the passed object to a primitive boolean.This method converts the internal value to a String object.This method will attempt to convert the value to a single value.toString()
static BooleanValue
valueOf
(boolean booleanValue) This method constructs a BooleanValue for the boolean passed as argument.static BooleanValue
This method attempts to convert the object to a BooleanValue.Methods inherited from class com.aquima.interactions.foundation.types.AbstractValue
getDisplayValue, getTypeName, isRangeValue, isSingleValue, toListValue, toRangeValue
-
Field Details
-
TRUE
This member defines the TRUE value for the boolean type. -
FALSE
This member defines the FALSE value for the boolean type. -
UNKNOWN
This member defines the UNKNOWN value for the boolean type.
-
-
Constructor Details
-
BooleanValue
protected BooleanValue()Constructs an unknown boolean value. This constructor is for internal use only, and the preferred method of acquiring an unknown boolean is by using the predefined static UNKNOWN member. -
BooleanValue
public BooleanValue(boolean booleanValue) Constructs a boolean value from a boolean primitive.- Parameters:
booleanValue
- The boolean primitive that should be used as value.
-
BooleanValue
Constructs a boolean value with a display text.- Parameters:
displayValue
- The display text that should be used for the value.booleanValue
- The boolean primitive value for this value.
-
BooleanValue
Constructs a boolean value with a type name and display text.- Parameters:
typeName
- The type name (domain) for the value.displayValue
- The display text that should be used for the value.booleanValue
- The boolean primitive value for this value.
-
BooleanValue
Copy constructor.- Parameters:
other
- value to copy.
-
-
Method Details
-
valueOf
This method constructs a BooleanValue for the boolean passed as argument.- Parameters:
booleanValue
- The boolean for which a BooleanValue is requested.- Returns:
- A BooleanValue for the boolean.
-
valueOf
This method attempts to convert the object to a BooleanValue. An empty string or null value will be converted to UNKNOWN. An integer value of one or zero will be converted to TRUE or FALSE. A string containing 'true' or 'yes' will be converted to TRUE. A string containing 'false' or 'no' will be converted to FALSE. A boolean will be converted to the corresponding BooleanValue.- Parameters:
obj
- The object that should be converted to a boolean value.- Returns:
- The BooleanValue for the object.
- Throws:
ConversionException
- This exception is thrown when the object could not be converted to a BooleanValue.
-
parseBoolean
This method will convert the passed object to a primitive boolean. If the argument is null or cannot be converted to a boolean, a ConversionException is thrown.- Parameters:
obj
- The object that should be converted to a boolean.- Returns:
- boolean value of the object.
-
contains
Description copied from interface:IValue
This method returns a boolean indicating if the object passed to this method is entirely part of this value. This method will thus also return true when the object passed is equal to this value, but the method will return false when only part (or none) of the object is represented by this value. Note that for value types that are singular in nature (for instance, implementations of ISingleValue) the operation of this method is limited to an equality check.- Specified by:
contains
in interfaceIValue
- Specified by:
contains
in classAbstractValue
- Parameters:
objValue
- Object for which should be checked if it is entirely part of this value.- Returns:
- boolean indicating if the object passed is entirely part of this value.
-
getDataType
Description copied from interface:IValue
This method returns the data type of the value.- Specified by:
getDataType
in interfaceIValue
- Specified by:
getDataType
in classAbstractValue
- Returns:
- The data type of the value.
-
forType
Description copied from interface:IPrimitiveValue
This method adds the type and display information to the value, and returns the value with this added information. The method will not change the state of the value the method is invoked on, but it will return a copy of the current value with the added information.- Specified by:
forType
in interfaceIPrimitiveValue
- Specified by:
forType
in classAbstractValue
- Parameters:
typeName
- The type of the value.displayValue
- Multilingual text containing display values.- Returns:
- The value with the added information.
-
isUnknown
public boolean isUnknown()Description copied from interface:IValue
This method returns a boolean indicating if the value is unknown.- Specified by:
isUnknown
in interfaceIValue
- Specified by:
isUnknown
in classAbstractValue
- Returns:
- boolean indicating if the value is unknown.
-
toSingleValue
Description copied from interface:IValue
This method will attempt to convert the value to a single value. The conversion might fail and raise an exception when the value this method is called on is either a range or a list value. The method isSingleValue can be used to determine if this value can safely be converted to a single value. When the value this method is called on already implements the ISingleValue interface, the implementation may return the same value.- Specified by:
toSingleValue
in interfaceIValue
- Overrides:
toSingleValue
in classAbstractValue
- Returns:
- The same value as single value.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Object>
- Overrides:
compareTo
in classAbstractValue
-
toString
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractValue
-
equals
- Overrides:
equals
in classAbstractValue
-
getValue
Description copied from interface:IConvertable
This method returns the internal object of this instance without any conversion.- Specified by:
getValue
in interfaceIConvertable
- Specified by:
getValue
in classAbstractValue
- Returns:
- The internal Object of this attribute value.
-
booleanValue
public boolean booleanValue()Description copied from interface:IConvertable
This method converts the internal value to a boolean primitive.- Specified by:
booleanValue
in interfaceIConvertable
- Specified by:
booleanValue
in classAbstractValue
- Returns:
- Boolean primitive of the internal value.
-
dateValue
Description copied from interface:IConvertable
This method converts the internal value to a date object.- Specified by:
dateValue
in interfaceIConvertable
- Specified by:
dateValue
in classAbstractValue
- Returns:
- Date object of the internal value.
-
doubleValue
public double doubleValue()Description copied from interface:IConvertable
This method converts the internal value to a double primitive.- Specified by:
doubleValue
in interfaceIConvertable
- Specified by:
doubleValue
in classAbstractValue
- Returns:
- Double primitive of the internal value.
-
integerValue
public int integerValue()Description copied from interface:IConvertable
This method converts the internal value to an integer primitive.- Specified by:
integerValue
in interfaceIConvertable
- Specified by:
integerValue
in classAbstractValue
- Returns:
- Integer primitive of the internal value.
-
longValue
public long longValue()Description copied from interface:IConvertable
This method converts the internal value to a long primitive.- Specified by:
longValue
in interfaceIConvertable
- Specified by:
longValue
in classAbstractValue
- Returns:
- Long primitive of the internal value.
-
stringValue
Description copied from interface:IConvertable
This method converts the internal value to a String object.- Specified by:
stringValue
in interfaceIConvertable
- Specified by:
stringValue
in classAbstractValue
- Returns:
- String object of the internal value.
-
compareSimple
- Specified by:
compareSimple
in classAbstractValue
-
duplicate
Description copied from interface:IValue
This method returns a deep copy of the value.- Specified by:
duplicate
in interfaceIValue
- Specified by:
duplicate
in classAbstractValue
- Returns:
- A deep clone.
-