Package jsonvalues
Class ImmutableJsons.ImmutableJsObjs
- java.lang.Object
-
- jsonvalues.ImmutableJsons.ImmutableJsObjs
-
- Enclosing class:
- ImmutableJsons
public class ImmutableJsons.ImmutableJsObjs extends Object
represents a factory of immutable Json objects
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsObj
empty()
Returns the immutable empty object.JsObj
of(String key, JsElem el)
Returns a one-element immutable object.JsObj
of(String key1, JsElem el1, String key2, JsElem el2)
Returns a two-element immutable object.JsObj
of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3)
Returns a three-element immutable object.JsObj
of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4)
Returns a four-element immutable 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 immutable 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 immutable object.JsObj
of(JsPair pair, JsPair... others)
Returns an immutable object from one or more pairs.JsObj
ofIterable(Iterable<Map.Entry<String,JsElem>> xs)
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
toImmutable(JsObj mutable)
-
-
-
Method Detail
-
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 immutable object.- Parameters:
key
- name of a keyel
- JsElem to be associated to the key- Returns:
- an immutable one-element JsObj
- Throws:
UserError
- if an elem is a mutable Json
-
of
public JsObj of(String key1, JsElem el1, String key2, JsElem el2)
Returns a two-element immutable 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 immutable two-element JsObj
- Throws:
UserError
- if an elem is a mutable Json
-
of
public JsObj of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3)
Returns a three-element immutable 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 immutable three-element JsObj
- Throws:
UserError
- if an elem is a mutable 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 immutable 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 immutable four-element JsObj
- Throws:
UserError
- if an elem is a mutable 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 immutable 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 immutable five-element JsObj
- Throws:
UserError
- if an elem is a mutable 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 immutable 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 immutable six-element JsObj
- Throws:
UserError
- if an elem is a mutable Json
-
of
public JsObj of(JsPair pair, JsPair... others)
Returns an immutable object from one or more pairs.- Parameters:
pair
- a pairothers
- more optional pairs- Returns:
- an immutable JsObject
- Throws:
UserError
- if an elem of a pair is mutable
-
-