Interface ObjectConverter
- All Known Implementing Classes:
ObjectConverterDefault
-
Method Summary
Modifier and TypeMethodDescriptionintCompare two elements.byte[]convertBase64StringToByteArray(Object element) Converts the element to aBigDecimal.convertByteArrayToBase64String(byte[] byteArray) Converts the element to aBase64 String.<T> TTries 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.booleanisAtLeastOneEquivalentElementInCommon(Collection<?> col1, Collection<?> col2) Do the two Collections have at least one equivalent element in common?booleanisBase64StringOrNull(Object element) Returnstrueif the element is a valid base 64 String, or isnull.booleanisCanBeConvertedTo(Class<?> referenceType, Object element) Can the element be converted to the specifiedreferenceType?booleanisCanBeConvertedToBigDecimal(Object element) Can the element be converted to aBigDecimal?booleanisCanBeConvertedToBoolean(Object element) Can the element be converted to aBoolean?booleanisCanBeConvertedToByteArray(Object element) Can the element be converted to abyte[]?booleanCan the element be converted to aDate? The source element must follow the Json date format.booleanisCanBeConvertedToDouble(Object element) Can the element be converted to aDouble?booleanisCanBeConvertedToFloat(Object element) Can the element be converted to aFloat?booleanisCanBeConvertedToInteger(Object element) Can the element be converted to aInteger?booleanisCanBeConvertedToJsonArray(Object element) Can the element be converted to aJsonArray?booleanisCanBeConvertedToJsonObject(Object element) Can the element be converted to aJsonObject?booleanisCanBeConvertedToLong(Object element) Can the element be converted to aLong?booleanisCanBeConvertedToString(Object element) Can the element be converted to aString?booleanisEquivalent(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
Returnstrueif 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
Booleanif its already a Boolean, if it'snullor 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'snullor 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
elementToCompareso it can be compared withcompareTo. It is also possible that we have to convertcompareTo, for the comparison to be possible. For example, ifcompareTois Long(10) andelementToCompareis 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
elementToCompareso it can be compared withcompareTo. It is also possible that we have to convertcompareTo, for the comparison to be possible. For example, ifcompareTois Long(10) andelementToCompareis 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?
-