Class RangeValue
java.lang.Object
com.aquima.interactions.foundation.convert.Convertable
com.aquima.interactions.foundation.types.RangeValue
- All Implemented Interfaces:
IConvertable
,IPrimitiveValue
,IRangeValue
,IValue
,Serializable
,Comparable<Object>
- Direct Known Subclasses:
AttributeRangeValue
This class holds a range consisting of two values.
- Since:
- 5.0
- Author:
- O. Kerpershoek
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
RangeValue
(IRangeValue range) RangeValue
(ISingleValue lowerValue, boolean lowerIncluded, ISingleValue upperValue, boolean upperIncluded) Constructs the range with a lower and upper bound. -
Method Summary
Modifier and TypeMethodDescriptionstatic int
compareRanges
(IRangeValue first, IRangeValue other) This method may be used to compare two ranges.int
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
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.getDisplayValue
(ILanguage language) getDisplayValue
(String languageCode, IValueFormatter formatter) This method returns a string that can be used as display value for the specified language.This method returns the lower value of the range.This method will return the (optional) type name of the value.This method returns the upper value of the range.getValue()
This method returns the internal object of this instance without any conversion.int
hashCode()
boolean
This method returns a boolean indicating if the lower value is part of the range.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 returns a boolean indicating if the value is unknown.boolean
This method returns a boolean indicating if the upper value is part of the range.static IRangeValue
lessThan
(ISingleValue singleValue, boolean inclusive) This method may be used to construct a range representing all the values less than the provided value.static IRangeValue
moreThan
(ISingleValue singleValue, boolean inclusive) This method may be used to construct a range representing all the values that are greater than the provided value.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 IRangeValue
This method may be used to convert an object to a range.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
-
RangeValue
public RangeValue(ISingleValue lowerValue, boolean lowerIncluded, ISingleValue upperValue, boolean upperIncluded) Constructs the range with a lower and upper bound.- Parameters:
lowerValue
- The lower bound of the range.lowerIncluded
- Boolean indicating if the lower bound is part of the range.upperValue
- The upper bound of the range.upperIncluded
- Boolean indicating if the upper bound is part of the range.
-
RangeValue
-
-
Method Details
-
valueOf
This method may be used to convert an object to a range.- Parameters:
obj
- The object that should be converted to a range.- Returns:
- The range for the specified object.
-
lessThan
This method may be used to construct a range representing all the values less than the provided value.- Parameters:
singleValue
- The upper bound of the range that should be created.inclusive
- Boolean indicating if the upper bound is part of the range.- Returns:
- The range consisting of all the value that are less than the provided value.
-
moreThan
This method may be used to construct a range representing all the values that are greater than the provided value.- Parameters:
singleValue
- The lower bound of the range that should be created.inclusive
- Boolean indicating if the lower bound is part of the range.- Returns:
- The range consisting of all the values that are greater than the provided value.
-
compareRanges
This method may be used to compare two ranges. When there is any overlap between the two ranges, the value 0 will be returned. When the upper bound of the first range lies below the lower bound of the second, the value -1 will be returned. When the lower bound of the first range lies above the upper bound of the second, the value 1 will be returned.- Parameters:
first
- The first range.other
- The second range.- Returns:
- The result of the compare.
-
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.
-
getTypeName
Description copied from interface:IPrimitiveValue
This method will return the (optional) type name of the value. The type name is available when the value belongs to a typed set like a domain or entity. In case the value is part of a domain, the type name will contain the name of the domain the value belongs to.- Specified by:
getTypeName
in interfaceIPrimitiveValue
- Returns:
- The 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
- Parameters:
typeName
- The type of the value.displayValue
- Multilingual text containing display values.- Returns:
- The value with the added information.
-
getDisplayValue
-
getDisplayValue
Description copied from interface:IPrimitiveValue
This method returns a string that can be used as display value for the specified language.- Specified by:
getDisplayValue
in interfaceIPrimitiveValue
- Parameters:
languageCode
- the code of the languageformatter
- optional formatter- Returns:
- A string containing the display value for the specified language.
-
isUnknown
public boolean isUnknown()Description copied from interface:IValue
This method returns a boolean indicating if the value is unknown. -
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.
-
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.
-
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.
-
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.
-
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. -
getLowerValue
Description copied from interface:IRangeValue
This method returns the lower value of the range.- Specified by:
getLowerValue
in interfaceIRangeValue
- Returns:
- The lower value of the range.
-
getUpperValue
Description copied from interface:IRangeValue
This method returns the upper value of the range.- Specified by:
getUpperValue
in interfaceIRangeValue
- Returns:
- The upper value of the range.
-
isLowerIncluded
public boolean isLowerIncluded()Description copied from interface:IRangeValue
This method returns a boolean indicating if the lower value is part of the range. When this method returns true the range will start and include the lower value.- Specified by:
isLowerIncluded
in interfaceIRangeValue
- Returns:
- Boolean indicating whether the lower value is part of the range.
-
isUpperIncluded
public boolean isUpperIncluded()Description copied from interface:IRangeValue
This method returns a boolean indicating if the upper value is part of the range. When this method returns true the range will end at, and include, the upper value.- Specified by:
isUpperIncluded
in interfaceIRangeValue
- Returns:
- Boolean indicating whether the upper value is part of the range.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Object>
-
equals
-
hashCode
public int hashCode() -
toString
-
duplicate
Description copied from interface:IValue
This method returns a deep copy of the value.
-