Package com.adobe.acs.commons.util
Class TypeUtil
java.lang.Object
com.adobe.acs.commons.util.TypeUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Map<T,T> arrayToMap(T[] list) Turn a even length Array into a Map.static <T> Class<T>Determines the type of the parameter object.toMap(com.google.gson.JsonObject json) Convenience wrapper for toMap(jsonObj, Object.class).static <T> TtoObjectType(String data, Class<T> klass) Converts a limited set of String representations to their corresponding Objectsstatic StringAttempt to create a string representation of an object.static StringGets the default string representation of the parameter object.static StringGets a custom string representation based on the parameter (0 argument) methodName.static org.apache.sling.api.resource.ValueMaptoValueMap(Map<String, ?> map) Transforms a Map of &lgt;String, ?> into a ValueMap.
-
Method Details
-
arrayToMap
Turn a even length Array into a Map. The Array is expected to be in the format: { key1, value1, key2, value2, ... , keyN, valueN }- Type Parameters:
T-- Parameters:
list-- Returns:
-
toMap
Convenience wrapper for toMap(jsonObj, Object.class).- Parameters:
json-- Returns:
-
getType
Determines the type of the parameter object. TODO - review this method- Type Parameters:
T-- Parameters:
object-- Returns:
-
toObjectType
Converts a limited set of String representations to their corresponding Objects Supports * Double * Long * Integer * Boolean (true/false) * Dates in string format of ISODateTimeFormat Else, null is returned.- Type Parameters:
T- the target class type of the provided data- Parameters:
data- the String representation of the dataklass- the target class type of the provided data- Returns:
- the derived object representing the data as specified by the klass
-
toString
public static String toString(Object obj, Class<?> klass) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException Gets the default string representation of the parameter object.- Parameters:
obj-klass-- Returns:
- Throws:
IllegalAccessExceptionNoSuchMethodExceptionInvocationTargetException
-
toString
public static String toString(Object obj, Class<?> klass, String methodName) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException Gets a custom string representation based on the parameter (0 argument) methodName.- Parameters:
obj-klass-methodName-- Returns:
- Throws:
InvocationTargetExceptionIllegalAccessExceptionNoSuchMethodException
-
toString
public static String toString(Object obj) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException Attempt to create a string representation of an object.- Parameters:
obj- the object to represent as a string- Returns:
- the string representation of the object
- Throws:
InvocationTargetExceptionIllegalAccessExceptionNoSuchMethodException
-
toValueMap
Transforms a Map of &lgt;String, ?> into a ValueMap.- Parameters:
map-- Returns:
- a ValueMap of the parameter map
-