Package jsonvalues
Class MutableJsons.MutableJsObjs
- java.lang.Object
-
- jsonvalues.MutableJsons.MutableJsObjs
-
- Enclosing class:
- MutableJsons
public class MutableJsons.MutableJsObjs extends Object
represents a factory of mutable Json objects
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collector<JsPair,JsObj,JsObj>
collector()
Returns a collector that accumulates the pairs from a stream into an mutable object.JsObj
empty()
Returns the immutable empty object.JsObj
of(String key, JsElem el)
Returns a one-element mutable object.JsObj
of(String key1, JsElem el1, String key2, JsElem el2)
Returns a two-element mutable object.JsObj
of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3)
Returns a three-element mutable object.JsObj
of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4)
Returns a four-element mutable object.JsObj
of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4, String key5, JsElem el5)
Returns a five-element mutable object.JsObj
of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4, String key5, JsElem el5, String key6, JsElem el6)
Returns a six-element mutable object.JsObj
of(JsPair pair, JsPair... others)
Returns an immutable object from one or more pairs.TryObj
parse(String str)
Tries to parse the string into an immutable object.TryObj
parse(String str, ParseBuilder builder)
Tries to parse the string into an immutable object, performing the specified transformations during the parsing.JsObj
toMutable(JsObj map)
-
-
-
Method Detail
-
collector
public Collector<JsPair,JsObj,JsObj> collector()
Returns a collector that accumulates the pairs from a stream into an mutable object.- Returns:
- a Collector which collects all the pairs of elements into an mutable JsObj, in encounter order
-
empty
public JsObj empty()
Returns the immutable empty object. The same instance is always returned.- Returns:
- the singleton immutable empty JsObj
-
parse
public TryObj parse(String str)
Tries to parse the string into an immutable object.- Parameters:
str
- the string to be parsed- Returns:
- a
TryObj
computation
-
parse
public TryObj parse(String str, ParseBuilder builder)
Tries to parse the string into an immutable object, performing the specified transformations during the parsing. It's faster to do certain operations right while the parsing instead of doing the parsing and applying them later.- Parameters:
str
- string to be parsedbuilder
- builder with the transformations that will be applied during the parsing- Returns:
- a
TryObj
computation
-
of
public JsObj of(String key, JsElem el)
Returns a one-element mutable object.- Parameters:
key
- name of a keyel
- JsElem to be associated to the key- Returns:
- an mutable one-element JsObj
- Throws:
UserError
- if an elem is an immutable Json
-
of
public JsObj of(String key1, JsElem el1, String key2, JsElem el2)
Returns a two-element mutable object.- Parameters:
key1
- name of a keyel1
- JsElem to be associated to the key1key2
- name of a keyel2
- JsElem to be associated to the key2- Returns:
- an mutable two-element JsObj
- Throws:
UserError
- if an elem is an immutable Json
-
of
public JsObj of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3)
Returns a three-element mutable object.- Parameters:
key1
- name of a keyel1
- JsElem to be associated to the key1key2
- name of a keyel2
- JsElem to be associated to the key2key3
- name of a keyel3
- JsElem to be associated to the key3- Returns:
- an mutable three-element JsObj
- Throws:
UserError
- if an elem is an immutable Json
-
of
public JsObj of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4)
Returns a four-element mutable object.- Parameters:
key1
- name of a keyel1
- JsElem to be associated to the key1key2
- name of a keyel2
- JsElem to be associated to the key2key3
- name of a keyel3
- JsElem to be associated to the key3key4
- name of a keyel4
- JsElem to be associated to the key4- Returns:
- an mutable four-element JsObj
- Throws:
UserError
- if an elem is an immutable Json
-
of
public JsObj of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4, String key5, JsElem el5)
Returns a five-element mutable object.- Parameters:
key1
- name of a keyel1
- JsElem to be associated to the key1key2
- name of a keyel2
- JsElem to be associated to the key2key3
- name of a keyel3
- JsElem to be associated to the key3key4
- name of a keyel4
- JsElem to be associated to the key4key5
- name of a keyel5
- JsElem to be associated to the key5- Returns:
- an mutable five-element JsObj
- Throws:
UserError
- if an elem is an immutable Json
-
of
public JsObj of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4, String key5, JsElem el5, String key6, JsElem el6)
Returns a six-element mutable object.- Parameters:
key1
- name of a keyel1
- JsElem to be associated to the key1key2
- name of a keyel2
- JsElem to be associated to the key2key3
- name of a keyel3
- JsElem to be associated to the key3key4
- name of a keyel4
- JsElem to be associated to the key4key5
- name of a keyel5
- JsElem to be associated to the key5key6
- name of a keyel6
- JsElem to be associated to the key6- Returns:
- an mutable six-element JsObj
- Throws:
UserError
- if an elem is an immutable Json
-
-