Package jsonvalues
Interface JsObj
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description 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)
this.intersection(that, SET)
returns an array with the elements that exist in boththis
andthat
this.intersection(that, MULTISET)
returns an array with the elements that exist in boththis
andthat
, being duplicates allowed.JsObj
intersection_(JsObj that, JsArray.TYPE ARRAY_AS)
this.intersection_(that)
behaves asthis.intersection(that, LIST)
, but for those elements that are containers of the same type and are located at the same position, the result is their intersection.default boolean
isObj()
boolean
same(JsObj other)
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)
returnsthis
json object plus those pairs from the given json objectthat
which keys don't exist inthis
.JsObj
union_(JsObj that, JsArray.TYPE ARRAY_AS)
behaves like theunion(JsObj)
but, for those keys that exit in boththis
andthat
json objects, which associated elements are **containers of the same type**, the result is their union.-
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, isSameType, isStr, isStr, isTrue
-
Methods inherited from interface jsonvalues.Json
add, add, add, add, add, add, add, append, append, append, append, append, append, append, appendAll, appendAllIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, appendIfPresent, containsElem, containsElem_, containsPath, equals, filterElems, filterElems_, filterKeys, filterKeys_, filterObjs, filterObjs_, get, get, getArray, getBigDecimal, getBigInt, getBool, getDouble, getInt, getLong, getObj, getStr, ifEmptyElse, isEmpty, isImmutable, isMutable, isNotEmpty, map, mapElems, mapElems, mapElems_, mapElems_, mapKeys, mapKeys, mapKeys_, mapKeys_, mapObjs, mapObjs, mapObjs_, mapObjs_, merge, patch, prepend, prepend, prepend, prepend, prepend, prepend, prepend, prependAll, prependAllIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, prependIfPresent, put, put, put, put, put, put, put, put, putIf, putIfAbsent, putIfAbsent, putIfAbsent, putIfAbsent, putIfPresent, putIfPresent, putIfPresent, putIfPresent, reduce, reduce_, remove, size, size, size_, size_, stream, stream_, times, times_
-
-
-
-
Method Detail
-
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
-
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:
UserError
- if this json object is empty
-
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:
UserError
- if this json object is empty
-
intersection
JsObj intersection(JsObj that, JsArray.TYPE ARRAY_AS)
this.intersection(that, SET)
returns an array with the elements that exist in boththis
andthat
this.intersection(that, MULTISET)
returns an array with the elements that exist in boththis
andthat
, being duplicates allowed.this.intersection(that, LIST)
returns an array with the elements that exist in boththis
andthat
, and are located at the same position.- 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)
this.intersection_(that)
behaves asthis.intersection(that, LIST)
, but for those elements that are containers of the same type and are located at the same position, the result is their intersection. So this operation is kind of a 'recursive' intersection.- 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)
returnsthis
json object plus those pairs from the given json objectthat
which keys don't exist inthis
. Taking that into account, it's not a commutative operation unless the elements associated with the keys that exist in both json objects are equals.- Parameters:
that
- the given json object- Returns:
- a new JsObj of the same type as the inputs (mutable or immutable)
-
union_
JsObj union_(JsObj that, JsArray.TYPE ARRAY_AS)
behaves like theunion(JsObj)
but, for those keys that exit in boththis
andthat
json objects, which associated elements are **containers of the same type**, the result is their union. In this case, we can specify if arrays are considered Sets, Lists, or MultiSets. So this operation is kind of a 'recursive' union.- Parameters:
that
- the given json 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)
-
ifEmptyElse
default <T> Trampoline<T> ifEmptyElse(Trampoline<T> empty, BiFunction<Map.Entry<String,JsElem>,JsObj,Trampoline<T>> fn)
-
isObj
default boolean isObj()
-
same
boolean same(JsObj other)
-
-