public class JsonSerializable extends Object
Modifier | Constructor and Description |
---|---|
protected |
JsonSerializable() |
protected |
JsonSerializable(byte[] bytes) |
protected |
JsonSerializable(ByteBuffer byteBuffer) |
protected |
JsonSerializable(com.fasterxml.jackson.databind.node.ObjectNode objectNode)
Constructor.
|
protected |
JsonSerializable(String jsonString)
Constructor.
|
protected |
JsonSerializable(String jsonString,
com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected Object |
get(String propertyName)
Gets a property value as Object.
|
protected Boolean |
getBoolean(String propertyName)
Gets a boolean value.
|
protected <T> Collection<T> |
getCollection(String propertyName,
Class<T> c,
boolean... convertFromCamelCase)
Gets an object collection.
|
protected Double |
getDouble(String propertyName)
Gets a double value.
|
protected Integer |
getInt(String propertyName)
Gets an integer value.
|
protected <T> List<T> |
getList(String propertyName,
Class<T> c,
boolean... convertFromCamelCase)
Gets an object List.
|
protected org.slf4j.Logger |
getLogger() |
protected Long |
getLong(String propertyName)
Gets a long value.
|
protected Map<String,Object> |
getMap()
Returns the propertybag(JsonNode) in a hashMap
|
protected <T> T |
getObject(String propertyName,
Class<T> c,
boolean... convertFromCamelCase)
Gets an object value.
|
protected Object |
getObjectByPath(List<String> propertyNames)
Gets the value of a property identified by an array of property names that forms the path.
|
protected com.fasterxml.jackson.databind.node.ObjectNode |
getPropertyBag() |
protected String |
getString(String propertyName)
Gets a string value.
|
protected boolean |
has(String propertyName)
Checks whether a property exists.
|
protected void |
populatePropertyBag() |
protected void |
remove(String propertyName)
Removes a value by propertyName.
|
protected ByteBuffer |
serializeJsonToByteBuffer()
Serialize json to byte buffer byte buffer.
|
protected <T> void |
set(String propertyName,
T value)
Sets the value of a property.
|
protected String |
toJson()
Converts to a JSON string.
|
protected String |
toJson(SerializationFormattingPolicy formattingPolicy)
Converts to a JSON string.
|
protected <T> T |
toObject(Class<T> c)
Converts to an Object (only POJOs and JsonNode are supported).
|
String |
toString()
Gets Simple STRING representation of property bag.
|
protected JsonSerializable()
protected JsonSerializable(String jsonString, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
jsonString
- the json string that represents the JsonSerializable.objectMapper
- the custom object mapperprotected JsonSerializable(String jsonString)
jsonString
- the json string that represents the JsonSerializable.protected JsonSerializable(com.fasterxml.jackson.databind.node.ObjectNode objectNode)
objectNode
- the ObjectNode
that represent the JsonSerializable
protected JsonSerializable(ByteBuffer byteBuffer)
protected JsonSerializable(byte[] bytes)
protected org.slf4j.Logger getLogger()
protected void populatePropertyBag()
protected Map<String,Object> getMap()
protected boolean has(String propertyName)
propertyName
- the property to look up.protected void remove(String propertyName)
propertyName
- the property to remove.protected <T> void set(String propertyName, T value)
T
- the type of the object.propertyName
- the property to set.value
- the value of the property.protected Object get(String propertyName)
propertyName
- the property to get.protected String getString(String propertyName)
propertyName
- the property to get.@Nullable protected Boolean getBoolean(String propertyName)
propertyName
- the property to get.protected Integer getInt(String propertyName)
propertyName
- the property to get.protected Long getLong(String propertyName)
propertyName
- the property to get.protected Double getDouble(String propertyName)
propertyName
- the property to get.protected <T> T getObject(String propertyName, Class<T> c, boolean... convertFromCamelCase)
T
- the type of the object.propertyName
- the property to get.c
- the class of the object. If c is a POJO class, it must be a member (and not an anonymous or local)
and a static one.convertFromCamelCase
- boolean indicating if String should be converted from camel case to upper case
separated by underscore,
before converting to required class.IllegalStateException
- thrown if an error occursprotected <T> List<T> getList(String propertyName, Class<T> c, boolean... convertFromCamelCase)
T
- the type of the objects in the List.propertyName
- the property to getc
- the class of the object. If c is a POJO class, it must be a member (and not an anonymous or local)
and a static one.convertFromCamelCase
- boolean indicating if String should be converted from camel case to upper case
separated by underscore,
before converting to required class.IllegalStateException
- thrown if an error occursprotected <T> Collection<T> getCollection(String propertyName, Class<T> c, boolean... convertFromCamelCase)
T
- the type of the objects in the collection.propertyName
- the property to getc
- the class of the object. If c is a POJO class, it must be a member (and not an anonymous or local)
and a static one.convertFromCamelCase
- boolean indicating if String should be converted from camel case to upper case
separated by underscore,
before converting to required class.protected Object getObjectByPath(List<String> propertyNames)
propertyNames
- that form the path to the property to get.protected ByteBuffer serializeJsonToByteBuffer()
protected <T> T toObject(Class<T> c)
T
- the type of the object.c
- the class of the object, either a POJO class or JsonNode. If c is a POJO class, it must be a member
(and not an anonymous or local) and a static one.IllegalArgumentException
- thrown if an error occursIllegalStateException
- thrown when objectmapper is unable to read treeprotected String toJson()
protected String toJson(SerializationFormattingPolicy formattingPolicy)
formattingPolicy
- the formatting policy to be used.public String toString()
For proper conversion to json and inclusion of the default values
use JsonSerializable.toJson()
.
protected com.fasterxml.jackson.databind.node.ObjectNode getPropertyBag()
Copyright © 2020 Microsoft Corporation. All rights reserved.