Package jsonvalues
Interface JsObj
-
-
Field Summary
Fields Modifier and Type Field Description static long
serialVersionUID
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static Collector<JsPair,JsObj,JsObj>
_collector_()
Returns a collector that accumulates the pairs from a stream into an mutable object.static JsObj
_empty_()
Returns a mutable empty object.static JsObj
_of_(String key, JsElem el)
Returns a mutable one-pair object.static JsObj
_of_(String key1, JsElem el1, String key2, JsElem el2)
Returns a mutable two-pair object.static JsObj
_of_(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3)
Returns a mutable three-pair object.static JsObj
_of_(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4)
Returns a mutable four-pair object.static JsObj
_of_(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4, String key5, JsElem el5)
Returns a mutable five-pair object.static 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 mutable six-pair object.static JsObj
_of_(Map<String,JsElem> map)
Returns a mutable object from a map of elements.static JsObj
_of_(JsPair pair, JsPair... others)
Returns a mutable object from one or more pairs.static TryObj
_parse_(String str)
Tries to parse the string into a mutable json object.static TryObj
_parse_(String str, ParseOptions options)
Tries to parse the string into an mutable object, performing some operations while the parsing.static Collector<JsPair,JsObj,JsObj>
collector()
Returns a collector that accumulates the pairs from a stream into an immutable object.static JsObj
empty()
Returns the immutable empty object.default boolean
equals(JsObj that, JsArray.TYPE ARRAY_AS)
return true if this obj is equal to the given as a parameter.Set<String>
fields()
Returns a set containing each key fo this object.Map.Entry<String,JsElem>
head()
Returns a pair with an arbitrary key of this object and its associated element.default <T> Trampoline<T>
ifEmptyElse(Trampoline<T> empty, BiFunction<Map.Entry<String,JsElem>,JsObj,Trampoline<T>> fn)
JsObj
intersection(JsObj that, JsArray.TYPE ARRAY_AS)
Returns the intersection of this object and another, defining characteristics like order and duplicates occurrence in arrays with the given ARRAY_AS parameter.JsObj
intersection_(JsObj that, JsArray.TYPE ARRAY_AS)
Returns the intersection of this object and another given as parameter applying recursively the intersection to those elements which are Json of the same type and are located at the same key and defining characteristics like order and duplicates occurrence in arrays with the given ARRAY_AS parameter.static JsObj
of(String key, JsElem el)
Returns an immutable one-element object.static JsObj
of(String key1, JsElem el1, String key2, JsElem el2)
Returns a two-element immutable object.static JsObj
of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3)
Returns a three-element immutable json object.static JsObj
of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4)
Returns a four-element immutable object.static 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.static 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.static JsObj
of(Map<String,JsElem> map)
Returns a immutable object from a map of elements.static JsObj
of(JsPair pair, JsPair... others)
Returns an immutable object from one or more pairs.static TryObj
parse(String str)
Tries to parse the string into an immutable object.static TryObj
parse(String str, ParseOptions options)
Tries to parse the string into an immutable object, performing some operations during the parsing.default JsObj
remove(String key)
Removes the key from this object if it's present.JsObj
tail(String key)
Returns a new object with all the entries of this json object except the one with the given key.JsObj
union(JsObj that)
Returns the union of this object and another given as a parameter.JsObj
union_(JsObj that, JsArray.TYPE ARRAY_AS)
Returns the union of this object and another given as parameter applying recursively the union to those elements which are Json of the same type and are located at the same key and defining characteristics like order and duplicates occurrence in arrays with the given ARRAY_AS parameter.-
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Methods inherited from interface jsonvalues.JsElem
asJsArray, asJsBigDec, asJsBigInt, asJsBool, asJsDouble, asJsInt, asJsLong, asJsObj, asJson, asJsStr, isArray, isArray, isBigDec, isBigDec, isBigInt, isBigInt, isBool, isDecimal, isDouble, isDouble, isFalse, isInstant, isInstant, isInt, isInt, isIntegral, isJson, isJson, isLocalDate, isLocalDate, isLocalDateTime, isLocalDateTime, isLong, isLong, isNothing, isNotJson, isNotNothing, isNotNull, isNotNumber, isNull, isNumber, isObj, isObj, isStr, isStr, isTrue
-
Methods inherited from interface jsonvalues.Json
append, append, append, append, append, append, append, append, append, append, append, append, append, append, appendAll, appendAll, appendAllIfPresent, appendAllIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, containsElem, containsElem_, containsPath, containsPath, equals, filterElems, filterElems_, filterKeys, filterKeys_, filterObjs, filterObjs_, get, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInt, getBigInt, getBool, getBool, getDouble, getDouble, getInt, getInt, getLong, getLong, getObj, getObj, getStr, getStr, ifEmptyElse, isEmpty, isImmutable, isMutable, isNotEmpty, map, mapElems, mapElems, mapElems_, mapElems_, mapKeys, mapKeys, mapKeys_, mapKeys_, mapObjs, mapObjs, mapObjs_, mapObjs_, merge, merge, prepend, prepend, prepend, prepend, prepend, prepend, prepend, prepend, prepend, prepend, prepend, prepend, prepend, prepend, prependAll, prependAll, prependAllIfPresent, prependAllIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, put, put, put, put, put, put, put, put, put, put, putIf, putIf, putIfAbsent, putIfAbsent, putIfAbsent, putIfAbsent, putIfAbsent, putIfAbsent, putIfAbsent, putIfAbsent, putIfPresent, putIfPresent, putIfPresent, putIfPresent, putIfPresent, putIfPresent, putIfPresent, putIfPresent, reduce, reduce_, remove, size, size, size, size_, size_, size_, stream, stream_, times, times_, toImmutable, toMutable
-
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Method Detail
-
_empty_
static JsObj _empty_()
Returns a mutable empty object.- Returns:
- a mutable empty JsObj
-
_of_
static JsObj _of_(String key, JsElem el)
Returns a mutable one-pair object.- Parameters:
key
- name of the keyel
- JsElem to be associated to the key- Returns:
- a mutable one-pair JsObj
- Throws:
UnsupportedOperationException
- if the elem is an immutable Json
-
_of_
static JsObj _of_(String key1, JsElem el1, String key2, JsElem el2)
Returns a mutable two-pair 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:
- a two-pair mutable JsObj
- Throws:
UnsupportedOperationException
- if an elem is an immutable Json
-
_of_
static JsObj _of_(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3)
Returns a mutable three-pair 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:
- a three-pair mutable JsObj
- Throws:
UnsupportedOperationException
- if an elem is an immutable Json
-
_of_
static JsObj _of_(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4)
Returns a mutable four-pair 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:
- a mutable four-pair JsObj
- Throws:
UnsupportedOperationException
- if an elem is an immutable Json
-
_of_
static JsObj _of_(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3, String key4, JsElem el4, String key5, JsElem el5)
Returns a mutable five-pair object.- Parameters:
key1
- name parse a keyel1
- JsElem to be associated to the key1key2
- name parse a keyel2
- JsElem to be associated to the key2key3
- name parse a keyel3
- JsElem to be associated to the key3key4
- name parse a keyel4
- JsElem to be associated to the key4key5
- name parse a keyel5
- JsElem to be associated to the key5- Returns:
- a mutable five-element JsObj
- Throws:
UnsupportedOperationException
- if an elem is an immutable Json
-
_of_
static 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 mutable six-pair object.- Parameters:
key1
- name parse a keyel1
- JsElem to be associated to the key1key2
- name parse a keyel2
- JsElem to be associated to the key2key3
- name parse a keyel3
- JsElem to be associated to the key3key4
- name parse a keyel4
- JsElem to be associated to the key4key5
- name parse a keyel5
- JsElem to be associated to the key5key6
- name parse a keyel6
- JsElem to be associated to the key6- Returns:
- a mutable six-element JsObj
- Throws:
UnsupportedOperationException
- if an elem is an immutable Json
-
_of_
static JsObj _of_(Map<String,JsElem> map)
Returns a mutable object from a map of elements.- Parameters:
map
- the map of JsElem- Returns:
- a mutable JsObj
- Throws:
UnsupportedOperationException
- if an elem of the map is an immutable Json
-
_parse_
static TryObj _parse_(String str)
Tries to parse the string into a mutable json object.- Parameters:
str
- the string to be parsed- Returns:
- a
TryObj
computation
-
equals
default boolean equals(JsObj that, JsArray.TYPE ARRAY_AS)
return true if this obj is equal to the given as a parameter. In the case of ARRAY_AS=LIST, this method is equivalent to JsObj.equals(Object).- Parameters:
that
- the given arrayARRAY_AS
- enum to specify if arrays are considered as lists or sets or multisets- Returns:
- true if both objs are equals
-
_parse_
static TryObj _parse_(String str, ParseOptions options)
Tries to parse the string into an mutable object, performing some operations while 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 parsedoptions
- a Options with the filters and maps that will be applied during the parsing- Returns:
- a
TryObj
computation
-
collector
static Collector<JsPair,JsObj,JsObj> collector()
Returns a collector that accumulates the pairs from a stream into an immutable object.- Returns:
- a Collector which collects all the pairs of elements into an immutable JsObj, in encounter order
-
_collector_
static 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
static JsObj empty()
Returns the immutable empty object. The same instance is always returned.- Returns:
- the singleton immutable empty JsObj
-
fields
Set<String> fields()
Returns a set containing each key fo this object.- Returns:
- a Set containing each key of this JsObj
-
head
Map.Entry<String,JsElem> head()
Returns a pair with an arbitrary key of this object and its associated element. When using head and tail to process a JsObj, the key of the pair returned must be passed in to get the tail using the methodtail(String)
.- Returns:
- an arbitrary
Map.Entry<String,JsElem>
of this JsObj - Throws:
UnsupportedOperationException
- if this json object is empty
-
of
static JsObj of(String key, JsElem el)
Returns an immutable one-element object.- Parameters:
key
- name of the keyel
- JsElem to be associated to the key- Returns:
- an immutable one-element JsObj
- Throws:
UnsupportedOperationException
- if the elem is a mutable Json
-
of
static 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:
UnsupportedOperationException
- if an elem is a mutable Json
-
of
static JsObj of(String key1, JsElem el1, String key2, JsElem el2, String key3, JsElem el3)
Returns a three-element immutable json 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:
UnsupportedOperationException
- if an elem is a mutable Json
-
of
static 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:
UnsupportedOperationException
- if an elem is a mutable Json
-
of
static 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:
UnsupportedOperationException
- if an elem is a mutable Json
-
of
static 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:
UnsupportedOperationException
- if an elem is a mutable Json
-
of
static JsObj of(Map<String,JsElem> map)
Returns a immutable object from a map of elements.- Parameters:
map
- the map of JsElem- Returns:
- an immutable JsObj
- Throws:
UnsupportedOperationException
- if an elem of the map is a mutable Json
-
parse
static 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
static TryObj parse(String str, ParseOptions options)
Tries to parse the string into an immutable object, performing some operations 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 parsedoptions
- a Options with the filters and maps that will be applied during the parsing- Returns:
- a
TryObj
computation
-
tail
JsObj tail(String key)
Returns a new object with all the entries of this json object except the one with the given key.- Parameters:
key
- the given key, which associated pair will be excluded- Returns:
- a new JsObj
- Throws:
UnsupportedOperationException
- if this json object is empty
-
intersection
JsObj intersection(JsObj that, JsArray.TYPE ARRAY_AS)
Returns the intersection of this object and another, defining characteristics like order and duplicates occurrence in arrays with the given ARRAY_AS parameter.- Parameters:
that
- the other objARRAY_AS
- option to define if arrays are considered SETS, LISTS OR MULTISET- Returns:
- a new JsObj of the same type as the inputs (mutable or immutable)
-
intersection_
JsObj intersection_(JsObj that, JsArray.TYPE ARRAY_AS)
Returns the intersection of this object and another given as parameter applying recursively the intersection to those elements which are Json of the same type and are located at the same key and defining characteristics like order and duplicates occurrence in arrays with the given ARRAY_AS parameter.- Parameters:
that
- the other objectARRAY_AS
- option to define if arrays are considered SETS, LISTS OR MULTISET- Returns:
- a new JsObj of the same type as the inputs (mutable or immutable)
-
union
JsObj union(JsObj that)
Returns the union of this object and another given as a parameter.- Parameters:
that
- the other object- Returns:
- a new JsObj of the same type as the inputs (mutable or immutable)
-
union_
JsObj union_(JsObj that, JsArray.TYPE ARRAY_AS)
Returns the union of this object and another given as parameter applying recursively the union to those elements which are Json of the same type and are located at the same key and defining characteristics like order and duplicates occurrence in arrays with the given ARRAY_AS parameter.- Parameters:
that
- the other objectARRAY_AS
- option to define if arrays are considered SETS, LISTS OR MULTISET- Returns:
- a new JsObj of the same type as the inputs (mutable or immutable)
-
of
static 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:
UnsupportedOperationException
- if an elem of a pair is mutable
-
_of_
static JsObj _of_(JsPair pair, JsPair... others)
Returns a mutable object from one or more pairs.- Parameters:
pair
- a pairothers
- more optional pairs- Returns:
- a mutable JsObject
- Throws:
UnsupportedOperationException
- if an elem of a pair is immutable
-
ifEmptyElse
default <T> Trampoline<T> ifEmptyElse(Trampoline<T> empty, BiFunction<Map.Entry<String,JsElem>,JsObj,Trampoline<T>> fn)
-
-