Class ObjectConverterDefault
- All Implemented Interfaces:
ObjectConverter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintCompare two elements.byte[]convertBase64StringToByteArray(Object object) 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 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 JsonManagerbooleanisAtLeastOneEquivalentElementInCommon(Collection<?> col1, Collection<?> col2) Do the two Collections have at least one equivalent element in common?booleanisBase64StringOrNull(Object object) Returnstrueif the element is a valid base 64 String, or isnull.booleanisCanBeConvertedTo(Class<?> referenceType, Object elementToValidate) Can the element be converted to the specifiedreferenceType?booleanisCanBeConvertedToBigDecimal(Object object) Can the element be converted to aBigDecimal?booleanisCanBeConvertedToBoolean(Object object) Can the element be converted to aBoolean?booleanisCanBeConvertedToByteArray(Object object) 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 object) Can the element be converted to aDouble?booleanisCanBeConvertedToFloat(Object object) Can the element be converted to aFloat?booleanisCanBeConvertedToInteger(Object object) Can the element be converted to aInteger?booleanisCanBeConvertedToJsonArray(Object object) Can the element be converted to aJsonArray?booleanisCanBeConvertedToJsonObject(Object object) Can the element be converted to aJsonObject?booleanisCanBeConvertedToLong(Object object) Can the element be converted to aLong?booleanisCanBeConvertedToString(Object object) Can the element be converted to aString?booleanisEquivalent(Object valueToCompare, Object compareTo) Are the two elements equivalent?
-
Constructor Details
-
ObjectConverterDefault
-
-
Method Details
-
getJsonManager
-
isCanBeConvertedTo
Description copied from interface:ObjectConverterCan the element be converted to the specifiedreferenceType?- Specified by:
isCanBeConvertedToin interfaceObjectConverter
-
isCanBeConvertedToString
Description copied from interface:ObjectConverterCan the element be converted to aString?- Specified by:
isCanBeConvertedToStringin interfaceObjectConverter
-
isCanBeConvertedToInteger
Description copied from interface:ObjectConverterCan the element be converted to aInteger?- Specified by:
isCanBeConvertedToIntegerin interfaceObjectConverter
-
isCanBeConvertedToLong
Description copied from interface:ObjectConverterCan the element be converted to aLong?- Specified by:
isCanBeConvertedToLongin interfaceObjectConverter
-
isCanBeConvertedToFloat
Description copied from interface:ObjectConverterCan the element be converted to aFloat?- Specified by:
isCanBeConvertedToFloatin interfaceObjectConverter
-
isCanBeConvertedToDouble
Description copied from interface:ObjectConverterCan the element be converted to aDouble?- Specified by:
isCanBeConvertedToDoublein interfaceObjectConverter
-
isCanBeConvertedToBoolean
Description copied from interface:ObjectConverterCan the element be converted to aBoolean?- Specified by:
isCanBeConvertedToBooleanin interfaceObjectConverter
-
isCanBeConvertedToBigDecimal
Description copied from interface:ObjectConverterCan the element be converted to aBigDecimal?- Specified by:
isCanBeConvertedToBigDecimalin interfaceObjectConverter
-
isCanBeConvertedToByteArray
Description copied from interface:ObjectConverterCan the element be converted to abyte[]?- Specified by:
isCanBeConvertedToByteArrayin interfaceObjectConverter
-
isCanBeConvertedToDateFromJsonDateFormat
Description copied from interface:ObjectConverterCan the element be converted to aDate? The source element must follow the Json date format.- Specified by:
isCanBeConvertedToDateFromJsonDateFormatin interfaceObjectConverter
-
isCanBeConvertedToJsonObject
Description copied from interface:ObjectConverterCan the element be converted to aJsonObject?- Specified by:
isCanBeConvertedToJsonObjectin interfaceObjectConverter
-
isCanBeConvertedToJsonArray
Description copied from interface:ObjectConverterCan the element be converted to aJsonArray?- Specified by:
isCanBeConvertedToJsonArrayin interfaceObjectConverter
-
isBase64StringOrNull
Description copied from interface:ObjectConverterReturnstrueif the element is a valid base 64 String, or isnull.- Specified by:
isBase64StringOrNullin interfaceObjectConverter
-
convertToJsonObject
Description copied from interface:ObjectConverterConverts the element to aJsonObject.- Specified by:
convertToJsonObjectin interfaceObjectConverter
-
convertToJsonArray
Description copied from interface:ObjectConverterConverts the element to aJsonArray.- Specified by:
convertToJsonArrayin interfaceObjectConverter
-
convertToString
Description copied from interface:ObjectConverterConverts the element to aJsonObject.- Specified by:
convertToStringin interfaceObjectConverter
-
convertToInteger
Description copied from interface:ObjectConverterConverts 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:
convertToIntegerin interfaceObjectConverter- Throws:
CantConvertException- if the element can't be converted to the required type.
-
convertToLong
Description copied from interface:ObjectConverterConverts 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:
convertToLongin interfaceObjectConverter- Throws:
CantConvertException- if the element can't be converted to the required type.
-
convertToFloat
Description copied from interface:ObjectConverterConverts the element to aFloat.- Specified by:
convertToFloatin interfaceObjectConverter- Throws:
CantConvertException- if the element can't be converted to the required type.
-
convertToDouble
Description copied from interface:ObjectConverterConverts the element to aDouble.- Specified by:
convertToDoublein interfaceObjectConverter- Throws:
CantConvertException- if the element can't be converted to the required type.
-
convertToBoolean
Description copied from interface:ObjectConverterConverts 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".- Specified by:
convertToBooleanin interfaceObjectConverter- Throws:
CantConvertException- if the element can't be converted to the required type.
-
convertToBigDecimal
Description copied from interface:ObjectConverterConverts the element to aBigDecimal.- Specified by:
convertToBigDecimalin interfaceObjectConverter- Throws:
CantConvertException- if the element can't be converted to the required type.
-
convertBase64StringToByteArray
Description copied from interface:ObjectConverterConverts the element to aBigDecimal.Can be converted to a
byte[]if its already abyte[], if it'snullor if it's a valid base 64String.- Specified by:
convertBase64StringToByteArrayin interfaceObjectConverter- Throws:
CantConvertException- if the element can't be converted to the required type.
-
convertByteArrayToBase64String
Description copied from interface:ObjectConverterConverts the element to aBase64 String.- Specified by:
convertByteArrayToBase64Stringin interfaceObjectConverter
-
convertToDateFromJsonDateFormat
Description copied from interface:ObjectConverterConverts the element to aDate.The source element must follow the Json date format (ISO 8601).
- Specified by:
convertToDateFromJsonDateFormatin interfaceObjectConverter- Throws:
CantConvertException- if the element can't be converted to the required type.
-
convertToInstantFromJsonDateFormat
Description copied from interface:ObjectConverterConverts the element to aInstant.The source element must follow the Json date format (ISO 8601).
- Specified by:
convertToInstantFromJsonDateFormatin interfaceObjectConverter- Throws:
CantConvertException- if the element can't be converted to the required type.
-
convertTo
Description copied from interface:ObjectConverterTries to convert the element to the specifiedtargetType.By default, only the types native to JsonObject are supported as the target types.
- Specified by:
convertToin interfaceObjectConverter- Throws:
CantConvertException- if the element can't be converted to the required type.
-
convertToJsonDateFormat
Description copied from interface:ObjectConverterConverts the date to a String representaiton compatible with the Json specification.- Specified by:
convertToJsonDateFormatin interfaceObjectConverter
-
compareTo
Description copied from interface:ObjectConverterCompare 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.- Specified by:
compareToin interfaceObjectConverter- Throws:
CantCompareException- if the elements can't be compared together.
-
isEquivalent
Description copied from interface:ObjectConverterAre 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.- Specified by:
isEquivalentin interfaceObjectConverter
-
isAtLeastOneEquivalentElementInCommon
Description copied from interface:ObjectConverterDo the two Collections have at least one equivalent element in common?- Specified by:
isAtLeastOneEquivalentElementInCommonin interfaceObjectConverter
-