public interface ObjectConverter
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Object elementToCompare,
Object compareTo)
Compare two elements.
|
byte[] |
convertBase64StringToByteArray(Object element)
Converts the element to a
BigDecimal. |
String |
convertByteArrayToBase64String(byte[] byteArray)
Converts the element to a
Base64 String. |
<T> T |
convertTo(Object element,
Class<T> targetType)
Tries to convert the element to the specified
targetType. |
BigDecimal |
convertToBigDecimal(Object element)
Converts the element to a
BigDecimal. |
Boolean |
convertToBoolean(Object element)
Converts the element to a
JsonArray. |
Date |
convertToDateFromJsonDateFormat(Object element)
Converts the element to a
Date. |
Double |
convertToDouble(Object element)
Converts the element to a
Double. |
Float |
convertToFloat(Object element)
Converts the element to a
Float. |
Integer |
convertToInteger(Object element)
Converts the element to a
Integer. |
JsonArray |
convertToJsonArray(Object element)
Converts the element to a
JsonArray. |
String |
convertToJsonDateFormat(Date date)
Converts the date to a String representaiton compatible with
the Json specification.
|
JsonObject |
convertToJsonObject(Object element)
Converts the element to a
JsonObject. |
Long |
convertToLong(Object element)
Converts the element to a
Long. |
String |
convertToString(Object element)
Converts the element to a
JsonObject. |
boolean |
isAtLeastOneEquivalentElementInCommon(Collection<?> col1,
Collection<?> col2)
Do the two Collections have at least one equivalent element
in common?
|
boolean |
isBase64StringOrNull(Object element)
Returns
true if the element is a valid base 64 String,
or is null. |
boolean |
isCanBeConvertedTo(Class<?> referenceType,
Object element)
Can the element be converted to the specified
referenceType? |
boolean |
isCanBeConvertedToBigDecimal(Object element)
Can the element be converted to a
BigDecimal? |
boolean |
isCanBeConvertedToBoolean(Object element)
Can the element be converted to a
Boolean? |
boolean |
isCanBeConvertedToByteArray(Object element)
Can the element be converted to a
byte[]? |
boolean |
isCanBeConvertedToDateFromJsonDateFormat(Object element)
Can the element be converted to a
Date? The source element must follow
the Json date format. |
boolean |
isCanBeConvertedToDouble(Object element)
Can the element be converted to a
Double? |
boolean |
isCanBeConvertedToFloat(Object element)
Can the element be converted to a
Float? |
boolean |
isCanBeConvertedToInteger(Object element)
Can the element be converted to a
Integer? |
boolean |
isCanBeConvertedToJsonArray(Object element)
Can the element be converted to a
JsonArray? |
boolean |
isCanBeConvertedToJsonObject(Object element)
Can the element be converted to a
JsonObject? |
boolean |
isCanBeConvertedToLong(Object element)
Can the element be converted to a
Long? |
boolean |
isCanBeConvertedToString(Object element)
Can the element be converted to a
String? |
boolean |
isEquivalent(Object elementToCompare,
Object compareTo)
Are the two elements equivalent?
|
boolean isCanBeConvertedTo(Class<?> referenceType, Object element)
referenceType?boolean isCanBeConvertedToString(Object element)
String?boolean isCanBeConvertedToInteger(Object element)
Integer?boolean isCanBeConvertedToLong(Object element)
Long?boolean isCanBeConvertedToFloat(Object element)
Float?boolean isCanBeConvertedToDouble(Object element)
Double?boolean isCanBeConvertedToBoolean(Object element)
Boolean?boolean isCanBeConvertedToBigDecimal(Object element)
BigDecimal?boolean isCanBeConvertedToByteArray(Object element)
byte[]?boolean isCanBeConvertedToDateFromJsonDateFormat(Object element)
Date? The source element must follow
the Json date format.boolean isCanBeConvertedToJsonObject(Object element)
JsonObject?boolean isCanBeConvertedToJsonArray(Object element)
JsonArray?boolean isBase64StringOrNull(Object element)
true if the element is a valid base 64 String,
or is null.JsonObject convertToJsonObject(Object element) throws CantConvertException
JsonObject.CantConvertException - if the element can't be converted to
the required type.JsonArray convertToJsonArray(Object element) throws CantConvertException
JsonArray.CantConvertException - if the element can't be converted to
the required type.Integer convertToInteger(Object element) throws CantConvertException
Integer.
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.
CantConvertException - if the element can't be converted to
the required type.Long convertToLong(Object element) throws CantConvertException
Long.
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.
CantConvertException - if the element can't be converted to
the required type.Float convertToFloat(Object element) throws CantConvertException
Float.CantConvertException - if the element can't be converted to
the required type.Double convertToDouble(Object element) throws CantConvertException
Double.CantConvertException - if the element can't be converted to
the required type.Boolean convertToBoolean(Object element) throws CantConvertException
JsonArray.
Il can be converted to a Boolean if its already a Boolean,
if it's null or if it's the String "true" or the String
"false".
CantConvertException - if the element can't be converted to
the required type.BigDecimal convertToBigDecimal(Object element) throws CantConvertException
BigDecimal.CantConvertException - if the element can't be converted to
the required type.byte[] convertBase64StringToByteArray(Object element) throws CantConvertException
BigDecimal.
Can be converted to a byte[] if its already a byte[],
if it's null or if it's a valid base 64 String.
CantConvertException - if the element can't be converted to
the required type.String convertByteArrayToBase64String(byte[] byteArray)
Base64 String.Date convertToDateFromJsonDateFormat(Object element) throws CantConvertException
Date.
The source element must follow the Json date format.
CantConvertException - if the element can't be converted to
the required type.<T> T convertTo(Object element, Class<T> targetType) throws CantConvertException
targetType.
By default, only the types native to JsonObject are supported as the target types.
CantConvertException - if the element can't be converted to
the required type.String convertToJsonDateFormat(Date date)
int compareTo(Object elementToCompare, Object compareTo) throws CantCompareException
If required, try to convert the elementToCompare so it
can be compared with compareTo. It is also possible
that we have to convert compareTo, for the comparison
to be possible. For example, if compareTo is Long(10) and
elementToCompare 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.
CantCompareException - if the elements can't be compared together.boolean isEquivalent(Object elementToCompare, Object compareTo)
If required, try to convert the elementToCompare so it
can be compared with compareTo. It is also possible
that we have to convert compareTo, for the comparison
to be possible. For example, if compareTo is Long(10) and
elementToCompare 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 return true.
boolean isAtLeastOneEquivalentElementInCommon(Collection<?> col1, Collection<?> col2)
#isEquivalent(Object, Object)}Copyright © 2016. All rights reserved.