public class JsonSerializable extends Object
Modifier | Constructor and Description |
---|---|
protected |
JsonSerializable() |
protected |
JsonSerializable(String jsonString)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
Object |
get(String propertyName)
Gets a property value as Object.
|
Boolean |
getBoolean(String propertyName)
Gets a boolean value.
|
<T> Collection<T> |
getCollection(String propertyName,
Class<T> c,
boolean... convertFromCamelCase)
Gets an object collection.
|
Double |
getDouble(String propertyName)
Gets a double value.
|
Integer |
getInt(String propertyName)
Gets an integer value.
|
<T> List<T> |
getList(String propertyName,
Class<T> c,
boolean... convertFromCamelCase)
Gets an object List.
|
protected org.slf4j.Logger |
getLogger() |
Long |
getLong(String propertyName)
Gets a long value.
|
Map<String,Object> |
getMap()
Returns the propertybag(JSONObject) in a hashMap
|
<T> T |
getObject(String propertyName,
Class<T> c,
boolean... convertFromCamelCase)
Gets an object value.
|
Object |
getObjectByPath(List<String> propertyNames)
Gets the value of a property identified by an array of property names that forms the path.
|
String |
getString(String propertyName)
Gets a string value.
|
boolean |
has(String propertyName)
Checks whether a property exists.
|
String |
toJson()
Converts to a JSON string.
|
String |
toJson(SerializationFormattingPolicy formattingPolicy)
Converts to a JSON string.
|
<T> T |
toObject(Class<T> c)
Converts to an Object (only POJOs and JSONObject are supported).
|
String |
toString()
Gets Simple STRING representation of property bag.
|
protected JsonSerializable()
protected JsonSerializable(String jsonString)
jsonString
- the json string that represents the JsonSerializable.protected org.slf4j.Logger getLogger()
public Map<String,Object> getMap()
public boolean has(String propertyName)
propertyName
- the property to look up.public Object get(String propertyName)
propertyName
- the property to get.public String getString(String propertyName)
propertyName
- the property to get.public Boolean getBoolean(String propertyName)
propertyName
- the property to get.public Integer getInt(String propertyName)
propertyName
- the property to get.public Long getLong(String propertyName)
propertyName
- the property to get.public Double getDouble(String propertyName)
propertyName
- the property to get.public <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 occurspublic <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 occurspublic <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.public Object getObjectByPath(List<String> propertyNames)
propertyNames
- that form the path to the property to get.public <T> T toObject(Class<T> c)
T
- the type of the object.c
- the class of the object, either a POJO class or JSONObject. 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 occurspublic String toJson()
public String toJson(SerializationFormattingPolicy formattingPolicy)
formattingPolicy
- the formatting policy to be used.Copyright © 2020 Microsoft Corporation. All rights reserved.