Class ListValue
java.lang.Object
com.aquima.interactions.foundation.convert.Convertable
com.aquima.interactions.foundation.types.ListValue
- All Implemented Interfaces:
IConvertable
,IListValue
,IValue
,Serializable
- Direct Known Subclasses:
AttributeListValue
,Domain
,DomainDefinition
,DomainValues
This class provides an implementation of the IListValue interface. This implementation also implements some other
interfaces, as a list of values can be treated as another type under certain conditions. A list that only contains a
single value, can be treated as a single value if, and only if, the value itself is a single value. The same goes for
the range interface, as a list containing a single range value, can be treated as a range.
- Since:
- 5.0
- Author:
- O. Kerpershoek
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a ListValue object with a datatype, resulting in an instance where isUnknown() is false.Construct a ListValue object with a datatype and isUniqueSet, resulting in an instance where isUnknown() is false.ListValue
(DataType datatype, IPrimitiveValue[] values) Construct a ListValue object with a datatype and an array of values, resulting in an instance where isUnknown() is false.ListValue
(DataType datatype, IPrimitiveValue[] values, boolean isUniqueSet) Construct a ListValue object with a datatype, an array of values and isUniqueSet, resulting in an instance where isUnknown() is false.ListValue
(IListValue other) Construct a ListValue object based on another ListValue.ListValue
(IPrimitiveValue[] values) Construct a ListValue object with an array of values, resulting in an instance where isUnknown() is false Note that values.length > 0, otherwise a InitialisationException is thrown.ListValue
(IPrimitiveValue[] values, boolean isUniqueSet) Construct a ListValue object with an array of values, resulting in an instance where isUnknown() is false Note that values.length > 0, otherwise a InitialisationException is thrown. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAll
(IPrimitiveValue[] values) This method can be used to add all the values from the array to the list.boolean
addValue
(IPrimitiveValue primitiveValue) This method can be used to add a value to the list.boolean
clearValues
(boolean setUnknown) This method can be used to remove all the values from the list.boolean
This method returns a boolean indicating if the object passed to this method is entirely part of this value.This method returns a deep copy of the value.boolean
This method returns the data type of the value.protected List
<IPrimitiveValue> This method will return the values from the list sorted using the compare method of the values.getValue()
This method returns the internal object of this instance without any conversion.getValueAt
(int index) This method will return the value at the specified index.int
This method will return the number of values that are present in the list.This method will return an array containing all the values from the list.int
hashCode()
protected void
insertValue
(int index, IPrimitiveValue primitiveValue) boolean
isEmpty()
This method will return a boolean indicating if the list contains no values.boolean
This method returns a boolean indicating if this value may safely be converted to a range value by using the toRangeValue method.boolean
This method returns a boolean indicating if this value may safely be converted to a single value by using the toSingleValue method.boolean
This method will return a boolean indicating if the list enforces all values to be unique.boolean
This method returns a boolean indicating if the value is unknown.boolean
removeValue
(IPrimitiveValue primitiveValue) This method can be used to remove a value from the list.This method will convert the current value to a list value.This method will attempt to convert the value to a range value.This method will attempt to convert the value to a single value.toString()
static IListValue
unknownFor
(DataType type) This method creates an unknown list of the specified type.Methods inherited from class com.aquima.interactions.foundation.convert.Convertable
booleanValue, dateValue, doubleValue, integerValue, longValue, stringValue
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.aquima.interactions.foundation.convert.IConvertable
booleanValue, dateValue, doubleValue, integerValue, longValue, stringValue
-
Constructor Details
-
ListValue
Construct a ListValue object with a datatype, resulting in an instance where isUnknown() is false. This List is a unique set, you can override this by using theListValue(DataType, boolean)
constructor- Parameters:
datatype
- The type of the values in the list.
-
ListValue
Construct a ListValue object with a datatype and isUniqueSet, resulting in an instance where isUnknown() is false.- Parameters:
datatype
- The type of the values in the list.isUniqueSet
- Boolean indicating if the list only allows unique values.
-
ListValue
Construct a ListValue object with an array of values, resulting in an instance where isUnknown() is false Note that values.length > 0, otherwise a InitialisationException is thrown. This List is a unique set, you can override this by using theListValue(IPrimitiveValue[], boolean)
constructor- Parameters:
values
- The values that should be put in the list.
-
ListValue
Construct a ListValue object with an array of values, resulting in an instance where isUnknown() is false Note that values.length > 0, otherwise a InitialisationException is thrown.- Parameters:
values
- The values that should be put in the list.isUniqueSet
- Boolean indicating if the list only allows unique values.
-
ListValue
Construct a ListValue object with a datatype and an array of values, resulting in an instance where isUnknown() is false. This List is a unique set, you can override this by using theListValue(DataType, IPrimitiveValue[], boolean)
constructor- Parameters:
datatype
- The type of the values in the list.values
- The values that should be put in the list.
-
ListValue
Construct a ListValue object with a datatype, an array of values and isUniqueSet, resulting in an instance where isUnknown() is false.- Parameters:
datatype
- The type of the values in the list.values
- The values that should be put in the list.isUniqueSet
- Boolean indicating if the list only allows unique values.
-
ListValue
Construct a ListValue object based on another ListValue.- Parameters:
other
- The list value that should be copied by this list.
-
-
Method Details
-
unknownFor
This method creates an unknown list of the specified type.- Parameters:
type
- The type of the list.- Returns:
- an unknown list of the specified type.
-
isUniqueSet
public boolean isUniqueSet()Description copied from interface:IListValue
This method will return a boolean indicating if the list enforces all values to be unique. When a list is set to be unique, all duplicate values will be ignored, and each value will appear only once in the list.- Specified by:
isUniqueSet
in interfaceIListValue
- Returns:
- boolean indicating if all values in the list must be unique.
-
insertValue
-
addValue
This method can be used to add a value to the list. When adding multiple values to a unique set try to collect them and useaddAll(IPrimitiveValue[])
as checking if the value is already present every time can be expensive. AQ-9268 When a primitive value of type integer is added to a number list do not throw an exception because an integer is always a number.- Parameters:
primitiveValue
- The value that should be added.- Returns:
- Boolean indicating if the value was actually added.
-
addAll
This method can be used to add all the values from the array to the list.- Parameters:
values
- Array containing all the values that need to be added.
-
removeValue
This method can be used to remove a value from the list.- Parameters:
primitiveValue
- The value that should be removed.- Returns:
- A boolean indicating if the values was actually removed.
-
clearValues
public boolean clearValues(boolean setUnknown) This method can be used to remove all the values from the list.- Parameters:
setUnknown
- Boolean indicating if the list should be unknown after the clear action.- Returns:
- Boolean indicating if the clear action was successful.
-
getDataType
Description copied from interface:IValue
This method returns the data type of the value.- Specified by:
getDataType
in interfaceIValue
- Returns:
- The data type of the value.
-
isUnknown
public boolean isUnknown()Description copied from interface:IValue
This method returns a boolean indicating if the value is unknown. -
isSingleValue
public boolean isSingleValue()Description copied from interface:IValue
This method returns a boolean indicating if this value may safely be converted to a single value by using the toSingleValue method. Objects that are already a single value will always return true, but ranges and list values may return true when they only contain a single value.
Note: This method returns true when the value is convertible, it does not mean that the value can safely be casted to the ISingleValue interface.- Specified by:
isSingleValue
in interfaceIValue
- Returns:
- boolean indicating if the value represent a single value.
-
isRangeValue
public boolean isRangeValue()Description copied from interface:IValue
This method returns a boolean indicating if this value may safely be converted to a range value by using the toRangeValue method. Objects that are already a range or single value will always return true, but list values may return true when they only contain a single value.
Note: This method returns true when the value is convertable, it does not mean that the value can safely be casted to the IRangeValue interface.- Specified by:
isRangeValue
in interfaceIValue
- Returns:
- boolean indicating if the value represent a range value.
-
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
- Returns:
- The same value as single value.
-
toRangeValue
Description copied from interface:IValue
This method will attempt to convert the value to a range value. The conversion might fail and raise an exception when the value this method is called on is either a list value. The method isRangeValue can be used to determine if this value can safely be converted to a range value. When the value this method is called on already implements the IRangeValue interface, the implementation may return the same value.- Specified by:
toRangeValue
in interfaceIValue
- Returns:
- The same value as a range value.
-
toListValue
Description copied from interface:IValue
This method will convert the current value to a list value. This type of conversion is always possible for all IValue implementations. Values of type ISingleValue or IRangeValue will result in a list value containing the primitive value (list of size 1). When the value this method is called on already implements the IListValue interface, the implementation may return the same value.- Specified by:
toListValue
in interfaceIValue
- Returns:
- The same value as list.
-
isEmpty
public boolean isEmpty()Description copied from interface:IListValue
This method will return a boolean indicating if the list contains no values.- Specified by:
isEmpty
in interfaceIListValue
- Returns:
- boolean indicating if the list contains no values.
-
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. -
getValueCount
public int getValueCount()Description copied from interface:IListValue
This method will return the number of values that are present in the list. When the list value is UNKNOWN 0 will be returned.- Specified by:
getValueCount
in interfaceIListValue
- Returns:
- The number of values in the list.
-
getValueAt
Description copied from interface:IListValue
This method will return the value at the specified index. The index passed to this method is zero based, so the first element can be retrieved by invoking this method with 'index = 0', and the last element with 'index = getValueCount() - '.- Specified by:
getValueAt
in interfaceIListValue
- Parameters:
index
- Integer containing the index of the value that is requested.- Returns:
- The value at the specified index.
-
getValues
Description copied from interface:IListValue
This method will return an array containing all the values from the list. When the list does not contain any values, an empty array will be returned.- Specified by:
getValues
in interfaceIListValue
- Returns:
- Array containing all the values from the list.
-
getSortedValues
Description copied from interface:IListValue
This method will return the values from the list sorted using the compare method of the values. When the list does not contain any values, an empty list will be returned.- Specified by:
getSortedValues
in interfaceIListValue
- Returns:
- Array containing the sorted values from the list.
-
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 classConvertable
- Returns:
- The internal Object of this attribute value.
-
equals
-
hashCode
public int hashCode() -
toString
-
getInternalValues
-
duplicate
Description copied from interface:IValue
This method returns a deep copy of the value.
-