Interface ObjectConverter
- All Known Implementing Classes:
ObjectConverterDefault
-
Method Summary
Modifier and TypeMethodDescriptionint
Compare two elements.byte[]
convertBase64StringToByteArray
(Object element) 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 element) Converts the element to aBigDecimal
.convertToBoolean
(Object element) Converts the element to aJsonArray
.convertToDateFromJsonDateFormat
(Object element) Converts the element to aDate
.convertToDouble
(Object element) Converts the element to aDouble
.convertToFloat
(Object element) Converts the element to aFloat
.convertToInstantFromJsonDateFormat
(Object element) Converts the element to aInstant
.convertToInteger
(Object element) Converts the element to aInteger
.convertToJsonArray
(Object element) Converts the element to aJsonArray
.convertToJsonDateFormat
(Date date) Converts the date to a String representaiton compatible with the Json specification.convertToJsonObject
(Object element) Converts the element to aJsonObject
.convertToLong
(Object element) Converts the element to aLong
.convertToString
(Object element) Converts the element to aJsonObject
.boolean
isAtLeastOneEquivalentElementInCommon
(Collection<?> col1, Collection<?> col2) Do the two Collections have at least one equivalent element in common?boolean
isBase64StringOrNull
(Object element) Returnstrue
if the element is a valid base 64 String, or isnull
.boolean
isCanBeConvertedTo
(Class<?> referenceType, Object element) Can the element be converted to the specifiedreferenceType
?boolean
isCanBeConvertedToBigDecimal
(Object element) Can the element be converted to aBigDecimal
?boolean
isCanBeConvertedToBoolean
(Object element) Can the element be converted to aBoolean
?boolean
isCanBeConvertedToByteArray
(Object element) 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 element) Can the element be converted to aDouble
?boolean
isCanBeConvertedToFloat
(Object element) Can the element be converted to aFloat
?boolean
isCanBeConvertedToInteger
(Object element) Can the element be converted to aInteger
?boolean
isCanBeConvertedToJsonArray
(Object element) Can the element be converted to aJsonArray
?boolean
isCanBeConvertedToJsonObject
(Object element) Can the element be converted to aJsonObject
?boolean
isCanBeConvertedToLong
(Object element) Can the element be converted to aLong
?boolean
isCanBeConvertedToString
(Object element) Can the element be converted to aString
?boolean
isEquivalent
(Object elementToCompare, Object compareTo) Are the two elements equivalent?
-
Method Details
-
isCanBeConvertedTo
Can the element be converted to the specifiedreferenceType
? -
isCanBeConvertedToString
Can the element be converted to aString
? -
isCanBeConvertedToInteger
Can the element be converted to aInteger
? -
isCanBeConvertedToLong
Can the element be converted to aLong
? -
isCanBeConvertedToFloat
Can the element be converted to aFloat
? -
isCanBeConvertedToDouble
Can the element be converted to aDouble
? -
isCanBeConvertedToBoolean
Can the element be converted to aBoolean
? -
isCanBeConvertedToBigDecimal
Can the element be converted to aBigDecimal
? -
isCanBeConvertedToByteArray
Can the element be converted to abyte[]
? -
isCanBeConvertedToDateFromJsonDateFormat
Can the element be converted to aDate
? The source element must follow the Json date format. -
isCanBeConvertedToJsonObject
Can the element be converted to aJsonObject
? -
isCanBeConvertedToJsonArray
Can the element be converted to aJsonArray
? -
isBase64StringOrNull
Returnstrue
if the element is a valid base 64 String, or isnull
. -
convertToJsonObject
Converts the element to aJsonObject
.- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToJsonArray
Converts the element to aJsonArray
.- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToString
Converts the element to aJsonObject
. -
convertToInteger
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.
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToLong
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.
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToFloat
Converts the element to aFloat
.- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToDouble
Converts the element to aDouble
.- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToBoolean
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".- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToBigDecimal
Converts the element to aBigDecimal
.- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertBase64StringToByteArray
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
.- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertByteArrayToBase64String
Converts the element to aBase64 String
. -
convertToDateFromJsonDateFormat
Converts the element to aDate
.The source element must follow the Json date format (ISO 8601).
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToInstantFromJsonDateFormat
Converts the element to aInstant
.The source element must follow the Json date format (ISO 8601).
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertTo
Tries to convert the element to the specifiedtargetType
.By default, only the types native to JsonObject are supported as the target types.
- Throws:
CantConvertException
- if the element can't be converted to the required type.
-
convertToJsonDateFormat
Converts the date to a String representaiton compatible with the Json specification. -
compareTo
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
.- Throws:
CantCompareException
- if the elements can't be compared together.
-
isEquivalent
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
. -
isAtLeastOneEquivalentElementInCommon
Do the two Collections have at least one equivalent element in common?
-