Class Converter
java.lang.Object
com.aquima.interactions.foundation.convert.Converter
- Direct Known Subclasses:
ProfileConverter
Utility class providing method to convert objects to IValue classes.
- Since:
- 5.0
- Author:
- O. Kerpershoek
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The default separator that is used to separate multiple elements in a string. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a converter without a delegate, thus providing standard conversion behavior.Converter
(IConverterDelegate delegate) This constructor accepts a delegate that will be used as a fallback when a certain object cannot be converted to the required data type by the normal conversion methods. -
Method Summary
Modifier and TypeMethodDescriptionThis method converts the passed object to a single primitive value of the specified data type.parseCollection
(Object objValue, DataType type, boolean alwaysReturnList) This method will convert the given object to a ListValue containing primitive values of the given type.parseCollection
(Object objValue, DataType type, boolean alwaysReturnList, boolean isUniqueSet) This method will convert the given object to a ListValue containing primitive values of the given type.protected EntityValue
parseEntity
(Object objValue) parseObject
(Object objValue, DataType type) This method will parse a given object to an IValue instance.static IPrimitiveValue
unknownFor
(DataType type) This method returns the unknown value for the specified data type.unknownValue
(DataType type) This method returns the unknown value for the specified data type.
-
Field Details
-
LISTVALUE_SEPARATOR
The default separator that is used to separate multiple elements in a string.- See Also:
-
-
Constructor Details
-
Converter
public Converter()Constructs a converter without a delegate, thus providing standard conversion behavior. -
Converter
This constructor accepts a delegate that will be used as a fallback when a certain object cannot be converted to the required data type by the normal conversion methods. The delegate will be invoked after the Converter has attempted to convert the object, but before the ConversionException is thrown.- Parameters:
delegate
- The delegate that should be used when the default conversion fails.
-
-
Method Details
-
unknownFor
This method returns the unknown value for the specified data type.- Parameters:
type
- The data type for which the unknown value is requested.- Returns:
- The unknown value for the specified data type.
-
unknownValue
This method returns the unknown value for the specified data type.- Parameters:
type
- The data type for which the unknown value is requested.- Returns:
- The unknown value for the specified data type.
-
parseObject
This method will parse a given object to an IValue instance. Depending on the class of the argument, the return value will either be an IPrimitiveValue, an IListValue ornull
. When the provided object isnull
, thennull
is returned. When the provided object represents a plural of instances (when the object is a Collection, array, IListValue, Map or a string value that contains multiple values separated byLISTVALUE_SEPARATOR
), then the return value will be an IListValue. Otherwise, the return value is an IPrimitiveValue.- Parameters:
objValue
- The object that needs to be converted (can benull
).type
- The type the object needs to be converted to (cannot benull
).- Returns:
- an IPrimitiveValue, an IListValue or
null
. - Throws:
ConversionException
- This exception is thrown when the object could not be converted.
-
parseCollection
This method will convert the given object to a ListValue containing primitive values of the given type. Depending on the value of the alwaysReturnList parameter, this method may also return a single value or null when the alwaysReturnList is set to false. When the alwaysReturnList parameter is set to true this method will always return a valid IListValue object, but the object might be empty (no values).- Parameters:
objValue
- The object that needs to be converted.type
- The type the object needs to be converted to.alwaysReturnList
- Parameter used to indicate if the returned object must implement the IListValue interface.- Returns:
- IValue object containing the result.
- Throws:
ConversionException
- This exception is thrown when the object could not be converted.
-
parseCollection
public IValue parseCollection(Object objValue, DataType type, boolean alwaysReturnList, boolean isUniqueSet) This method will convert the given object to a ListValue containing primitive values of the given type. Depending on the value of the alwaysReturnList parameter, this method may also return a single value or null when the alwaysReturnList is set to false. When the alwaysReturnList parameter is set to true this method will always return a valid IListValue object, but the object might be empty (no values).- Parameters:
objValue
- The object that needs to be converted.type
- The type the object needs to be converted to.alwaysReturnList
- Parameter used to indicate if the returned object must implement the IListValue interface.isUniqueSet
- Parameter used to indicate if the list is unique or not.- Returns:
- IValue object containing the result.
- Throws:
ConversionException
- This exception is thrown when the object could not be converted.
-
parse
This method converts the passed object to a single primitive value of the specified data type.- Parameters:
obj
- The object that should be convertedtype
- The data type to which the value should be converted.- Returns:
- IPrimitiveValue containing the converted object
- Throws:
ConversionException
- This exception is thrown when the object could not be converted.
-
parseEntity
-