public class MapObjectConversion extends Object
This class creates Java objects from java.util.Lists and java.util.Maps. It is used by the JSON parser lib. There are map like objects that are index overlays of the parsed JSON. This set of utilties makes Java a bit more dynamic. This is the core of the serialization for JSON and works in conjunction with org.boon.core.Type.
| Modifier and Type | Class and Description |
|---|---|
static class |
MapObjectConversion.FieldToEntryConverter
Converts a field access set into a collection of map entries.
|
| Constructor and Description |
|---|
MapObjectConversion() |
| Modifier and Type | Method and Description |
|---|---|
static <T> List<T> |
convertListOfMapsToObjects(boolean respectIgnore,
String view,
FieldsAccessor fieldsAccessor,
Class<T> componentType,
List<?> list,
Set<String> ignoreProperties)
This converts a list of maps to objects.
|
static <T> T |
fromList(boolean respectIgnore,
String view,
FieldsAccessor fieldsAccessor,
List<?> argList,
Class<T> clazz,
Set<String> ignoreSet)
Convert an item from a list into a class using the classes constructor.
|
static <T> T |
fromList(FieldsAccessor fieldsAccessor,
List<?> argList,
Class<T> clazz)
Convert an item from a list into a class using the classes constructor.
|
static <T> T |
fromList(List<?> argList,
Class<T> clazz)
Convert an item from a list into a class using the classes constructor.
|
static <T> T |
fromListUsingFields(boolean respectIgnore,
String view,
FieldsAccessor fieldsAccessor,
List<Object> list,
Class<T> clazz,
Set<String> ignoreSet)
Create an object from a list using the fields of the class.
|
static <T> T |
fromListUsingFields(List<Object> list,
Class<T> clazz)
Create an object from a list using the fields of the class.
|
static <T> T |
fromMap(boolean respectIgnore,
String view,
FieldsAccessor fieldsAccessor,
Map<String,Object> map,
Class<T> cls,
Set<String> ignoreSet)
fromMap converts a map into a java object
|
static Object |
fromMap(Map<String,Object> map)
fromMap converts a map into a Java object.
|
static <T> T |
fromMap(Map<String,Object> map,
Class<T> clazz)
From map.
|
static <T> T |
fromMap(Map<String,Object> map,
Class<T> clazz,
String... excludeProperties)
fromMap converts a map into a java object.
|
static <T> T |
fromValueMap(boolean respectIgnore,
String view,
FieldsAccessor fieldsAccessor,
Map<String,Value> valueMap,
Class<T> cls,
Set<String> ignoreSet)
Creates an object from a value map.
|
static boolean |
matchAndConvertArgs(boolean respectIgnore,
String view,
FieldsAccessor fieldsAccessor,
List<Object> convertedArgumentList,
BaseAccess methodAccess,
Class[] parameterTypes,
int index,
Set<String> ignoreSet,
boolean[] flag,
boolean loose)
This converts/coerce a constructor argument to the given parameter type.
|
static List<?> |
toList(Object object)
Convert an object to a list.
|
static List<Map<String,Object>> |
toListOfMaps(Collection<?> collection)
Creates a list of maps from a list of class instances.
|
static Map<String,Object> |
toMap(Object object)
This could be refactored to use core.Type class and it would run faster.
|
static Map<String,Object> |
toMap(Object object,
Set<String> ignore)
This could be refactored to use core.Type class and it would run faster.
|
static Map<String,Object> |
toMap(Object object,
String... ignore)
Basic toMap to create an object into a map.
|
public static <T> T fromListUsingFields(List<Object> list, Class<T> clazz)
T - generic type of the object that we are creatinglist - list we are creating the object fromclazz - the type of object that we are creating.public static <T> T fromListUsingFields(boolean respectIgnore,
String view,
FieldsAccessor fieldsAccessor,
List<Object> list,
Class<T> clazz,
Set<String> ignoreSet)
T - generic type we are returningrespectIgnore - ignore things marked with @JsonIgnore and transient valuesview - the view of the object which can ignore certain fields given certain viewsfieldsAccessor - how we are going to access the fields (by field, by property, combination)list - list we are creating the object fromclazz - the type of object that we are creating.ignoreSet - a set of properties to ignorepublic static <T> T fromList(List<?> argList, Class<T> clazz)
T - genericsargList - list if argumentsclazz - the type of the object we are creatingpublic static <T> T fromList(boolean respectIgnore,
String view,
FieldsAccessor fieldsAccessor,
List<?> argList,
Class<T> clazz,
Set<String> ignoreSet)
T - genericsrespectIgnore - honor @JsonIgnore, transients, etc. of the fieldview - honor views for fieldsfieldsAccessor - how we are going to access the fields (by field, by property, combination)argList - list if argumentsclazz - the type of the object we are creatingignoreSet - a set of properties to ignorepublic static <T> T fromList(FieldsAccessor fieldsAccessor, List<?> argList, Class<T> clazz)
T - genericsfieldsAccessor - how we are going to access the fields (by field, by property, combination)argList - list if argumentsclazz - the type of the object we are creatingpublic static boolean matchAndConvertArgs(boolean respectIgnore,
String view,
FieldsAccessor fieldsAccessor,
List<Object> convertedArgumentList,
BaseAccess methodAccess,
Class[] parameterTypes,
int index,
Set<String> ignoreSet,
boolean[] flag,
boolean loose)
view - honor views for fieldsfieldsAccessor - how we are going to access the fields (by field, by property, combination)ignoreSet - a set of properties to ignorerespectIgnore - honor @JsonIgnore, transients, etc. of the fieldconvertedArgumentList - arguments being converted to match parameter typesmethodAccess - constructorparameterTypes - parameterTypesindex - index of argumentpublic static List<?> toList(Object object)
object - the object we want to convert to a listpublic static <T> T fromMap(Map<String,Object> map, Class<T> clazz)
T - generic type capturemap - map to create the object from.clazz - the new instance typepublic static <T> T fromMap(Map<String,Object> map, Class<T> clazz, String... excludeProperties)
T - generic type capturemap - map to create the object from.clazz - the new instance typeexcludeProperties - the properties to excludepublic static Object fromMap(Map<String,Object> map)
map - map to create the object from.public static <T> T fromMap(boolean respectIgnore,
String view,
FieldsAccessor fieldsAccessor,
Map<String,Object> map,
Class<T> cls,
Set<String> ignoreSet)
T - map to create teh object from.respectIgnore - honor @JsonIgnore, transients, etc. of the fieldview - the view of the object which can ignore certain fields given certain viewsfieldsAccessor - how we are going to access the fields (by field, by property, combination)map - map to create the object from.cls - class type of new objectignoreSet - a set of properties to ignorepublic static <T> T fromValueMap(boolean respectIgnore,
String view,
FieldsAccessor fieldsAccessor,
Map<String,Value> valueMap,
Class<T> cls,
Set<String> ignoreSet)
respectIgnore - honor @JsonIgnore, transients, etc. of the fieldview - the view of the object which can ignore certain fields given certain viewsfieldsAccessor - how we are going to access the fields (by field, by property, combination)cls - the new typeignoreSet - a set of properties to ignorepublic static Map<String,Object> toMap(Object object, String... ignore)
object - the object we want to convert to a listignore - do we honor ignore propertiespublic static Map<String,Object> toMap(Object object, Set<String> ignore)
object - the object that we want to convertignore - the mappublic static Map<String,Object> toMap(Object object)
object - the object that we want to convertpublic static <T> List<T> convertListOfMapsToObjects(boolean respectIgnore, String view, FieldsAccessor fieldsAccessor, Class<T> componentType, List<?> list, Set<String> ignoreProperties)
T - genericsrespectIgnore - honor @JsonIgnore, transients, etc. of the fieldview - the view of the object which can ignore certain fields given certain viewsfieldsAccessor - how we are going to access the fields (by field, by property, combination)componentType - The component type of the created listlist - the input listignoreProperties - properties to ignorepublic static List<Map<String,Object>> toListOfMaps(Collection<?> collection)
collection - the collection we are coercing into a field valueCopyright © 2014. All rights reserved.