Package org.icij.datashare.json
Class JsonObjectMapper
- java.lang.Object
-
- org.icij.datashare.json.JsonObjectMapper
-
public class JsonObjectMapper extends Object
JSON - POJO Index mapping functions Expect the following annotations from given (domain entity) objects@IndexId,@IndexType,@JSONCreator,@JSONPropertyCreated by julien on 6/29/16.
-
-
Field Summary
Fields Modifier and Type Field Description static com.fasterxml.jackson.databind.ObjectMapperMAPPER
-
Constructor Summary
Constructors Constructor Description JsonObjectMapper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Entity>
StringgetId(T obj)Get the field value marked withIndexIdfrom DataShare domain entity object instancestatic <T extends Entity>
Map<String,Object>getJson(T obj)Get JSON representation (as a Map) of an Object instancestatic <T extends Entity>
TgetObject(String id, String projectId, Map<String,Object> source, Class<T> type)static <T extends Entity>
StringgetParent(T obj)Get the field value marked with@IndexParentfrom DataShare domain entity object instancestatic <T extends Entity>
StringgetRoot(T obj)static StringgetType(Class<? extends Entity> cls)Get value ofIndexTypeannotation from Classstatic <T extends Entity>
StringgetType(T obj)Get the value ofIndexTypeannotation from DataShare domain entity Object instance
-
-
-
Method Detail
-
getJson
public static <T extends Entity> Map<String,Object> getJson(T obj)
Get JSON representation (as a Map) of an Object instance- Type Parameters:
T- the concrete type of entity- Parameters:
obj- the object to convert to JSON- Returns:
- JSON representation of
obj
-
getObject
public static <T extends Entity> T getObject(String id, String projectId, Map<String,Object> source, Class<T> type)
-
getType
public static String getType(Class<? extends Entity> cls)
Get value ofIndexTypeannotation from Class- Parameters:
cls- the class holding index type-annotated field- Returns:
- the index type String
-
getType
public static <T extends Entity> String getType(T obj)
Get the value ofIndexTypeannotation from DataShare domain entity Object instance- Type Parameters:
T- the concrete type of entity- Parameters:
obj- the object instance from which@IndexTypeis extracted- Returns:
- the index type String
-
getId
public static <T extends Entity> String getId(T obj)
Get the field value marked withIndexIdfrom DataShare domain entity object instance- Type Parameters:
T- the concrete type of entity- Parameters:
obj- the object holding the index id-annotated field- Returns:
- the index id String
-
getParent
public static <T extends Entity> String getParent(T obj)
Get the field value marked with@IndexParentfrom DataShare domain entity object instance- Type Parameters:
T- the concrete type of entity- Parameters:
obj- the object holding the index id-annotated field- Returns:
- the parent's hash String
-
-