Package tenapull.data.entity.template
Class ExtensibleJsonPojo
java.lang.Object
tenapull.data.entity.template.ExtensibleJsonPojo
- Direct Known Subclasses:
GeneratedIdPojo
,NaturalIdPojo
@MappedSuperclass
public abstract class ExtensibleJsonPojo
extends java.lang.Object
Abstract base class that implements ExtraJson behavior for most pojos other than string lookups.
Note that 'implements DbPojo' interface is delayed until NaturalIdPojo and GeneratedIdPojo,
because they have different requirement for how to implement id.
-
Constructor Summary
Constructors Constructor Description ExtensibleJsonPojo()
-
Method Summary
Modifier and Type Method Description protected void
__prepare()
Convienence method for subclass implementations to invoke from their _prepare() method (note the difference in number of underscores), which performs DB preparations on the ExtraJsonExtraJson
getExtraJson()
Gets extra json.com.fasterxml.jackson.databind.JsonNode
getExtraJson(java.lang.String key)
Gets extra json for a specific keyjava.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode>
getExtraJsonMap()
Gets extra json map for serializationvoid
putExtraJson(java.lang.String key, java.lang.Object value)
Puts extra json during deserializationvoid
setExtraJson(ExtraJson extraJson)
Sets entire extra json value.com.fasterxml.jackson.databind.node.ObjectNode
toJsonNode()
Converts the pojo into a serialized JSON ObjectNodejava.lang.String
toJsonString()
Serializes the pojo into a JSON stringjava.lang.String
toString()
Uses the toJsonString() method to convert to a JSON string, except catches any JsonProcessingException and returns an error message instead
-
Constructor Details
-
ExtensibleJsonPojo
public ExtensibleJsonPojo()
-
-
Method Details
-
getExtraJson
Gets extra json.- Returns:
- the extra json
-
setExtraJson
Sets entire extra json value.- Parameters:
extraJson
- the extra json
-
getExtraJsonMap
public java.util.Map<java.lang.String,com.fasterxml.jackson.databind.JsonNode> getExtraJsonMap()Gets extra json map for serialization- Returns:
- the extra json map
-
putExtraJson
public void putExtraJson(java.lang.String key, java.lang.Object value)Puts extra json during deserialization- Parameters:
key
- the keyvalue
- the value
-
getExtraJson
public com.fasterxml.jackson.databind.JsonNode getExtraJson(java.lang.String key)Gets extra json for a specific key- Parameters:
key
- the key- Returns:
- the extra json
-
__prepare
protected void __prepare()Convienence method for subclass implementations to invoke from their _prepare() method (note the difference in number of underscores), which performs DB preparations on the ExtraJson -
toJsonNode
public com.fasterxml.jackson.databind.node.ObjectNode toJsonNode()Converts the pojo into a serialized JSON ObjectNode- Returns:
- the object node
-
toJsonString
public java.lang.String toJsonString() throws com.fasterxml.jackson.core.JsonProcessingExceptionSerializes the pojo into a JSON string- Returns:
- the JSON string
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
- if there is json processing exception
-
toString
public java.lang.String toString()Uses the toJsonString() method to convert to a JSON string, except catches any JsonProcessingException and returns an error message instead- Overrides:
toString
in classjava.lang.Object
- Returns:
- the serialized JSON string, or an error message if serialization failed
-