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.
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<Map> list,
Set<String> ignoreProperties)
This converts a list of maps to objects.
|
static <T> List<T> |
convertListOfMapsToObjects(Class<T> componentType,
List<Map> list) |
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 |
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 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 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 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<Map> 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 <T> List<T> convertListOfMapsToObjects(Class<T> componentType, List<Map> list)
T
- componentType
- The component type of the created listlist
- the input listpublic static List<Map<String,Object>> toListOfMaps(Collection<?> collection)
collection
- the collection we are coercing into a field valueCopyright © 2014. All rights reserved.