Class ObjectConverterDefault
- All Implemented Interfaces:
ObjectConverter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Compare two elements.byte[]
convertBase64StringToByteArray
(Object object) Converts the element to aBigDecimal
.convertByteArrayToBase64String
(byte[] byteArray) Converts the element to aBase64 String
.<T> T
Tries to convert the element to the specifiedtargetType
.convertToBigDecimal
(Object object) Converts the element to aBigDecimal
.convertToBoolean
(Object object) Converts the element to aJsonArray
.Converts the element to aDate
.convertToDouble
(Object object) Converts the element to aDouble
.convertToFloat
(Object object) Converts the element to aFloat
.Converts the element to aInstant
.convertToInteger
(Object object) Converts the element to aInteger
.convertToJsonArray
(Object object) Converts the element to aJsonArray
.convertToJsonDateFormat
(Date date) Converts the date to a String representaiton compatible with the Json specification.convertToJsonObject
(Object object) Converts the element to aJsonObject
.convertToLong
(Object object) Converts the element to aLong
.convertToString
(Object object) Converts the element to aJsonObject
.protected JsonManager
boolean
isAtLeastOneEquivalentElementInCommon
(Collection<?> col1, Collection<?> col2) Do the two Collections have at least one equivalent element in common?boolean
isBase64StringOrNull
(Object object) Returnstrue
if the element is a valid base 64 String, or isnull
.boolean
isCanBeConvertedTo
(Class<?> referenceType, Object elementToValidate) Can the element be converted to the specifiedreferenceType
?boolean
isCanBeConvertedToBigDecimal
(Object object) Can the element be converted to aBigDecimal
?boolean
isCanBeConvertedToBoolean
(Object object) Can the element be converted to aBoolean
?boolean
isCanBeConvertedToByteArray
(Object object) Can the element be converted to abyte[]
?boolean
Can the element be converted to aDate
? The source element must follow the Json date format.boolean
isCanBeConvertedToDouble
(Object object) Can the element be converted to aDouble
?boolean
isCanBeConvertedToFloat
(Object object) Can the element be converted to aFloat
?boolean
isCanBeConvertedToInteger
(Object object) Can the element be converted to aInteger
?boolean
isCanBeConvertedToJsonArray
(Object object) Can the element be converted to aJsonArray
?boolean
isCanBeConvertedToJsonObject
(Object object) Can the element be converted to aJsonObject
?boolean
isCanBeConvertedToLong
(Object object) Can the element be converted to aLong
?boolean
isCanBeConvertedToString
(Object object) Can the element be converted to aString
?boolean
isEquivalent
(Object valueToCompare, Object compareTo) Are the two elements equivalent?
-
Constructor Details
-
ObjectConverterDefault
-
-
Method Details
-
getJsonManager
-
isCanBeConvertedTo
Description copied from interface:ObjectConverter
Can the element be converted to the specifiedreferenceType
?- Specified by:
isCanBeConvertedTo
in interfaceObjectConverter
-
isCanBeConvertedToString
Description copied from interface:ObjectConverter
Can the element be converted to aString
?- Specified by:
isCanBeConvertedToString
in interfaceObjectConverter
-
isCanBeConvertedToInteger
Description copied from interface:ObjectConverter
Can the element be converted to aInteger
?- Specified by:
isCanBeConvertedToInteger
in interfaceObjectConverter
-
isCanBeConvertedToLong
Description copied from interface:ObjectConverter
Can the element be converted to aLong
?- Specified by:
isCanBeConvertedToLong
in interfaceObjectConverter
-
isCanBeConvertedToFloat
Description copied from interface:ObjectConverter
Can the element be converted to aFloat
?- Specified by:
isCanBeConvertedToFloat
in interfaceObjectConverter
-
isCanBeConvertedToDouble
Description copied from interface:ObjectConverter
Can the element be converted to aDouble
?- Specified by:
isCanBeConvertedToDouble
in interfaceObjectConverter
-
isCanBeConvertedToBoolean
Description copied from interface:ObjectConverter
Can the element be converted to aBoolean
?- Specified by:
isCanBeConvertedToBoolean
in interfaceObjectConverter
-
isCanBeConvertedToBigDecimal
Description copied from interface:ObjectConverter
Can the element be converted to aBigDecimal
?- Specified by:
isCanBeConvertedToBigDecimal
in interfaceObjectConverter
-
isCanBeConvertedToByteArray
Description copied from interface:ObjectConverter
Can the element be converted to abyte[]
?- Specified by:
isCanBeConvertedToByteArray
in interfaceObjectConverter
-
isCanBeConvertedToDateFromJsonDateFormat
Description copied from interface:ObjectConverter
Can the element be converted to aDate
? The source element must follow the Json date format.- Specified by:
isCanBeConvertedToDateFromJsonDateFormat
in interfaceObjectConverter
-
isCanBeConvertedToJsonObject
Description copied from interface:ObjectConverter
Can the element be converted to aJsonObject
?- Specified by:
isCanBeConvertedToJsonObject
in interfaceObjectConverter
-
isCanBeConvertedToJsonArray
Description copied from interface:ObjectConverter
Can the element be converted to aJsonArray
?- Specified by:
isCanBeConvertedToJsonArray
in interfaceObjectConverter
-
isBase64StringOrNull
Description copied from interface:ObjectConverter
Returnstrue
if the element is a valid base 64 String, or isnull
.- Specified by:
isBase64StringOrNull
in interfaceObjectConverter
-
convertToJsonObject
Description copied from interface:ObjectConverter
Converts the element to aJsonObject
.- Specified by:
convertToJsonObject
in interfaceObjectConverter
-
convertToJsonArray
Description copied from interface:ObjectConverter
Converts the element to aJsonArray
.- Specified by:
convertToJsonArray
in interfaceObjectConverter
-
convertToString
Description copied from interface:ObjectConverter
Converts the element to aJsonObject
.- Specified by:
convertToString
in interfaceObjectConverter
-
convertToInteger
Description copied from interface:ObjectConverter
Converts the element to aInteger
.The
toString()
method will be called on the object before trying to convert it to an Integer. If the resulting String contains zeros only decimals, those will be removed and the conversion will work.For example : "123.0" will work.
- Specified by:
convertToInteger
in interfaceObjectConverter
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToLong
Description copied from interface:ObjectConverter
Converts the element to aLong
.The
toString()
method will be called on the object before trying to convert it to a Long. If the resulting String contains zeros only decimals, those will be removed and the conversion will work.For example : "123.0" will work.
- Specified by:
convertToLong
in interfaceObjectConverter
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToFloat
Description copied from interface:ObjectConverter
Converts the element to aFloat
.- Specified by:
convertToFloat
in interfaceObjectConverter
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToDouble
Description copied from interface:ObjectConverter
Converts the element to aDouble
.- Specified by:
convertToDouble
in interfaceObjectConverter
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToBoolean
Description copied from interface:ObjectConverter
Converts the element to aJsonArray
.Il can be converted to a
Boolean
if its already a Boolean, if it'snull
or if it's the String "true" or the String "false".- Specified by:
convertToBoolean
in interfaceObjectConverter
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToBigDecimal
Description copied from interface:ObjectConverter
Converts the element to aBigDecimal
.- Specified by:
convertToBigDecimal
in interfaceObjectConverter
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertBase64StringToByteArray
Description copied from interface:ObjectConverter
Converts the element to aBigDecimal
.Can be converted to a
byte[]
if its already abyte[]
, if it'snull
or if it's a valid base 64String
.- Specified by:
convertBase64StringToByteArray
in interfaceObjectConverter
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertByteArrayToBase64String
Description copied from interface:ObjectConverter
Converts the element to aBase64 String
.- Specified by:
convertByteArrayToBase64String
in interfaceObjectConverter
-
convertToDateFromJsonDateFormat
Description copied from interface:ObjectConverter
Converts the element to aDate
.The source element must follow the Json date format (ISO 8601).
- Specified by:
convertToDateFromJsonDateFormat
in interfaceObjectConverter
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToInstantFromJsonDateFormat
Description copied from interface:ObjectConverter
Converts the element to aInstant
.The source element must follow the Json date format (ISO 8601).
- Specified by:
convertToInstantFromJsonDateFormat
in interfaceObjectConverter
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertTo
Description copied from interface:ObjectConverter
Tries to convert the element to the specifiedtargetType
.By default, only the types native to JsonObject are supported as the target types.
- Specified by:
convertTo
in interfaceObjectConverter
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToJsonDateFormat
Description copied from interface:ObjectConverter
Converts the date to a String representaiton compatible with the Json specification.- Specified by:
convertToJsonDateFormat
in interfaceObjectConverter
-
compareTo
Description copied from interface:ObjectConverter
Compare two elements.If required, try to convert the
elementToCompare
so it can be compared withcompareTo
. It is also possible that we have to convertcompareTo
, for the comparison to be possible. For example, ifcompareTo
is Long(10) andelementToCompare
is BigDecimal(12.34), we have to convert both elements to BigDecimal so they can be compared.For a comparison to work, the two elements must be (after conversion or not) of the same type and this type must implement
Comparable
.- Specified by:
compareTo
in interfaceObjectConverter
- Throws:
CantCompareException
- if the elements can't be compared together.
-
isEquivalent
Description copied from interface:ObjectConverter
Are the two elements equivalent?If required, try to convert the
elementToCompare
so it can be compared withcompareTo
. It is also possible that we have to convertcompareTo
, for the comparison to be possible. For example, ifcompareTo
is Long(10) andelementToCompare
is BigDecimal(12.34), we have to convert both elements to BigDecimal so they can be compared.For the two elements to be equivalent, they must be (after conversion or not) of the same type and then the
Object.equals(Object)
method must returntrue
.- Specified by:
isEquivalent
in interfaceObjectConverter
-
isAtLeastOneEquivalentElementInCommon
Description copied from interface:ObjectConverter
Do the two Collections have at least one equivalent element in common?- Specified by:
isAtLeastOneEquivalentElementInCommon
in interfaceObjectConverter
-