public class JsObject extends Object
This is open source software released under the Apache 2.0 License
| Modifier and Type | Field and Description |
|---|---|
private int |
attributeCount |
private boolean |
ignoreNulls |
private boolean |
inline |
private JsCode |
script |
| Constructor and Description |
|---|
JsObject(JsCode script,
boolean inline)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
private JsObject |
createArray(Object key,
boolean inline,
Consumer<JsArray> consumer) |
private JsObject |
createObject(Object key,
Consumer<JsObject> consumer) |
JsObject |
newArray(Object key,
boolean inline,
Consumer<JsArray> consumer)
Adds an array attribute with the key specified
|
JsObject |
newArray(Object key,
Consumer<JsArray> consumer)
Adds an array attribute with the key specified
|
JsObject |
newAttribute(Object key,
Boolean value)
Adds an attribute value for the key provided
|
JsObject |
newAttribute(Object key,
Double value)
Adds an attribute value for the key provided
|
JsObject |
newAttribute(Object key,
Float value)
Adds an attribute value for the key provided
|
JsObject |
newAttribute(Object key,
Integer value)
Adds an attribute value for the key provided
|
JsObject |
newAttribute(Object key,
String value)
Adds an attribute value for the key provided
|
private JsObject |
newAttribute(String template,
Object key,
Object value)
Creates a new attribute with the key value provided
|
JsObject |
newObject(Object key,
Consumer<JsObject> consumer)
Adds an object attribute with the key specified
|
void |
setIgnoreNulls(boolean ignoreNulls)
Sets whether this object will ignore attempts to set null attributes
|
private JsCode script
private boolean inline
private int attributeCount
private boolean ignoreNulls
JsObject(JsCode script, boolean inline)
script - the script this object will write toinline - true to print this object on one linepublic void setIgnoreNulls(boolean ignoreNulls)
ignoreNulls - true to ignore null attributesprivate JsObject newAttribute(String template, Object key, Object value)
template - the string template to output key / value pairkey - the keyvalue - the valuepublic JsObject newAttribute(Object key, Boolean value)
key - the attribute keyvalue - the attribute valuepublic JsObject newAttribute(Object key, Integer value)
key - the attribute keyvalue - the attribute valuepublic JsObject newAttribute(Object key, Float value)
key - the attribute keyvalue - the attribute valuepublic JsObject newAttribute(Object key, Double value)
key - the attribute keyvalue - the attribute valuepublic JsObject newAttribute(Object key, String value)
key - the attribute keyvalue - the attribute valuepublic JsObject newObject(Object key, Consumer<JsObject> consumer)
key - the attribute keyconsumer - the consumer to configure objectpublic JsObject newArray(Object key, Consumer<JsArray> consumer)
key - the attribute keyconsumer - the consumer to populate the arrayCopyright 2014-2017, Xavier Witdouck