Package com.adobe.acs.commons.util
Class TypeUtil
- java.lang.Object
-
- com.adobe.acs.commons.util.TypeUtil
-
@ProviderType public final class TypeUtil extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Map<T,T>arrayToMap(T[] list)Turn a even length Array into a Map.static <T> Class<T>getType(Object object)Determines the type of the parameter object.static Map<String,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 StringtoString(Object obj)Attempt to create a string representation of an object.static StringtoString(Object obj, Class<?> klass)Gets the default string representation of the parameter object.static StringtoString(Object obj, Class<?> klass, String methodName)Gets 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 Detail
-
arrayToMap
public static <T> Map<T,T> arrayToMap(T[] list)
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
public static Map<String,Object> toMap(com.google.gson.JsonObject json)
Convenience wrapper for toMap(jsonObj, Object.class).- Parameters:
json-- Returns:
-
getType
public static <T> Class<T> getType(Object object)
Determines the type of the parameter object. TODO - review this method- Type Parameters:
T-- Parameters:
object-- Returns:
-
toObjectType
public static <T> T toObjectType(String data, Class<T> klass)
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
-
-