public final class ParaObjectUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <P extends ParaObject> |
fromJSON(String json)
Converts a JSON string to a domain object.
|
static Map<String,String> |
getAllTypes(App app)
Returns a map of all registered types.
|
static <P extends ParaObject> |
getAnnotatedFields(P pojo) |
static <P extends ParaObject> |
getAnnotatedFields(P pojo,
Class<? extends Annotation> filter) |
static <P extends ParaObject> |
getAnnotatedFields(P pojo,
Class<? extends Annotation> filter,
boolean convertNestedToJsonString)
Returns a map of annotated fields of a domain object.
|
static Map<String,Class<? extends ParaObject>> |
getCoreClassesMap()
Searches through the Para core package and
Config.CORE_PACKAGE_NAME package for ParaObject
subclasses and adds their names them to the map. |
static Map<String,String> |
getCoreTypes()
Returns a map of the core data types.
|
static com.fasterxml.jackson.databind.ObjectMapper |
getJsonMapper()
A Jackson
ObjectMapper. |
static com.fasterxml.jackson.databind.ObjectReader |
getJsonReader(Class<?> type)
A Jackson JSON reader.
|
static com.fasterxml.jackson.databind.ObjectWriter |
getJsonWriter()
A Jackson JSON writer.
|
static com.fasterxml.jackson.databind.ObjectWriter |
getJsonWriterNoIdent()
A Jackson JSON writer.
|
static <P extends ParaObject> |
populate(P transObject,
Map<String,String[]> paramMap)
Populates an object with an array of query parameters (dangerous!).
|
static <P extends ParaObject> |
setAnnotatedFields(Map<String,Object> data) |
static <P extends ParaObject> |
setAnnotatedFields(P pojo,
Map<String,Object> data,
Class<? extends Annotation> filter)
Converts a map of fields/values to a domain object.
|
static Class<? extends ParaObject> |
toClass(String type)
Converts a class name to a real Class object.
|
static Class<? extends ParaObject> |
toClass(String type,
Class<? extends ParaObject> defaultClass)
Converts a class name to a real
ParaObject subclass. |
static <P extends ParaObject> |
toJSON(P obj)
Converts a domain object to JSON.
|
static <P extends ParaObject> |
toObject(String type)
Constructs a new instance of a core object.
|
static boolean |
typesMatch(ParaObject so)
Checks if the type of an object matches its real Class name.
|
public static com.fasterxml.jackson.databind.ObjectMapper getJsonMapper()
ObjectMapper.public static com.fasterxml.jackson.databind.ObjectReader getJsonReader(Class<?> type)
type - the type to readpublic static com.fasterxml.jackson.databind.ObjectWriter getJsonWriter()
public static com.fasterxml.jackson.databind.ObjectWriter getJsonWriterNoIdent()
public static <P extends ParaObject> void populate(P transObject, Map<String,String[]> paramMap)
P - the object typetransObject - an objectparamMap - a query parameters mappublic static Map<String,String> getCoreTypes()
public static Map<String,String> getAllTypes(App app)
app - the app to search for custom typespublic static boolean typesMatch(ParaObject so)
so - an objectpublic static <P extends ParaObject> Map<String,Object> getAnnotatedFields(P pojo)
P - the object typepojo - the object to convert to a mapgetAnnotatedFields(com.erudika.para.core.ParaObject, java.lang.Class, boolean)public static <P extends ParaObject> Map<String,Object> getAnnotatedFields(P pojo, Class<? extends Annotation> filter)
P - the object typepojo - the object to convert to a mapfilter - a filter annotation. fields that have it will be skippedgetAnnotatedFields(com.erudika.para.core.ParaObject, java.lang.Class, boolean)public static <P extends ParaObject> Map<String,Object> getAnnotatedFields(P pojo, Class<? extends Annotation> filter, boolean convertNestedToJsonString)
convertNestedToJsonString is true all field values that are objects (i.e. not primitive types or
wrappers) are converted to a JSON string otherwise they are left as they are and will be serialized as regular
JSON objects later (structure is preserved). Null is considered a primitive type. Transient fields and
serialVersionUID are skipped.P - the object typepojo - the object to convert to a mapfilter - a filter annotation. fields that have it will be skippedconvertNestedToJsonString - true if you want to flatten the nested objects to a JSON string.public static <P extends ParaObject> P setAnnotatedFields(Map<String,Object> data)
P - the object typedata - the map of fields/valuessetAnnotatedFields(com.erudika.para.core.ParaObject, java.util.Map, java.lang.Class)public static <P extends ParaObject> P setAnnotatedFields(P pojo, Map<String,Object> data, Class<? extends Annotation> filter)
P - the object typepojo - the object to populate with datadata - the map of fields/valuesfilter - a filter annotation. fields that have it will be skippedpublic static <P extends ParaObject> P toObject(String type)
P - the object typetype - the simple name of a classSysprop.toClass(java.lang.String)public static Class<? extends ParaObject> toClass(String type)
type - the simple name of a classSysprop if the class was not found.Class.forName(java.lang.String)public static Class<? extends ParaObject> toClass(String type, Class<? extends ParaObject> defaultClass)
ParaObject subclass. Defaults to
Sysprop if the class was not found in the core package path.type - the simple name of a classdefaultClass - returns this type if the requested class was not found on the classpath.Class.forName(java.lang.String),
Sysproppublic static Map<String,Class<? extends ParaObject>> getCoreClassesMap()
Config.CORE_PACKAGE_NAME package for ParaObject
subclasses and adds their names them to the map.public static <P extends ParaObject> P fromJSON(String json)
Sysprop.P - type of object to convertjson - the JSON stringpublic static <P extends ParaObject> String toJSON(P obj)
P - type of object to convertobj - a domain objectCopyright © 2016 Erudika. All rights reserved.