T
- Type of container: either an object or an arrayJsElem
, Serializable
public interface Json<T extends Json<T>> extends JsElem, Serializable
Represents a json of type T, where T is the type of the container, either a JsObj or a JsArray. A json of any type can be modeled as a set of pairsJsPair
=(JsPath
,JsElem
), where: - a JsElem is aJsBool
orJsStr
orJsNumber
orJsNull
, or anotherJson
likeJsObj
orJsArray
, what makes the data structure recursive. - a JsPath represents the location of the element in the json. For example, the json { "a":1, "x":{ "c": true, "d":null, e: [false, 1, "hi"] } } can be seen as the following set: Set[(a,1), (x.c,true), (x.d,null), (x.e.0,false), (x.e.1,1), (x.e.2,"hi"), (_,NOTHING)] where _, which means any other JsPath, and the special elementJsNothing.NOTHING
, makes the functionget(JsPath)
total (defined for every possible path). Moreover, inserting JsNothing in a json doesn't change the json, which is very convenient when passing functions as parameters to put data in: //all the logic goes into the supplierSupplier<JsElem> supplier = ()-> (doesnt-put-anything-condition) ? JsNothing.NOTHING : JsInt.of(2); json.putIfAbsent(path,supplier)
Another way to see a json is like a stream of pairs, which opens the door to doing all the operations that were introduced in Java 8 (map, filter, reduce, etc). For this purpose the methodsstream_()
orstream()
are provided. To put the stream back into an immutable json the collectorsJsObj.collector()
andJsArray.collector()
can be used, whereas the collectorsJsObj._collector_()
andJsArray._collector_()
would put the stream back into a mutable json. All the methods that accept aJsPath
are overloaded and accept also a path-like string instead. There are two types of conventions on method names: -Static factory methods that are prefixed and suffixed with underscore return mutable instances. -Methods that are suffixed with underscore traverse the whole json recursively. All the methods throw a NullPointerException when any of the params passed in is null. The exceptionUnsupportedOperationException
is thrown when the user calls a method inappropriately: for example calling the methodasJsStr
in aJsNull
instance or calling the method head in an empty array, etc. Normally, when that happens, a previous check is missing.
to work with jsons that are objects
,
to work with jsons that are arrays
Modifier and Type | Field | Description |
---|---|---|
static long |
serialVersionUID |
Modifier and Type | Method | Description |
---|---|---|
static Try |
_parse_(String str) |
Tries to parse the string into a mutable json.
|
static Try |
_parse_(String str,
ParseOptions options) |
Tries to parse the string into a mutable json, performing some operations while the parsing.
|
default T |
append(String path,
boolean elem,
boolean... others) |
Appends one or more booleans, starting from the first, to the array located at the given path in
this json.
|
default T |
append(String path,
double elem,
double... others) |
Appends one or more doubles, starting from the first, to the array located at the given path in
this json.
|
default T |
append(String path,
int elem,
int... others) |
Appends one or more integers, starting from the first, to the array located at the given path in
this json.
|
default T |
append(String path,
long elem,
long... others) |
Appends one or more longs, starting from the first, to the array located at the given path in
this json.
|
default T |
append(String path,
String elem,
String... others) |
Appends one or more strings, starting from the first, to the array located at the given path in
this json.
|
default T |
append(String path,
JsElem elem) |
Appends one element to the array located at the given path in this json.
|
default T |
append(String path,
JsElem elem,
JsElem... others) |
Appends one or more elements, starting from the first, to the array located at the given path in
this json.
|
default T |
append(JsPath path,
boolean elem,
boolean... others) |
Appends one or more booleans, starting from the first, to the array located at the given path in
this json.
|
default T |
append(JsPath path,
double elem,
double... others) |
Appends one or more doubles, starting from the first, to the array located at the given path in
this json.
|
default T |
append(JsPath path,
int elem,
int... others) |
Appends one or more integers, starting from the first, to the array located at the given path in
this json.
|
default T |
append(JsPath path,
long elem,
long... others) |
Appends one or more longs, starting from the first, to the array located at the given path in
this json.
|
default T |
append(JsPath path,
String elem,
String... others) |
Appends one or more strings, starting from the first, to the array located at the given path in
this json.
|
T |
append(JsPath path,
JsElem elem) |
Appends one element to the array located at the given path in this json.
|
default T |
append(JsPath path,
JsElem elem,
JsElem... others) |
Appends one or more elements, starting from the first, to the array located at the given path in
this json.
|
default T |
appendAll(String path,
JsArray elems) |
Appends all the elements of the array, starting from the head, to the array located at the given
path in this json.
|
T |
appendAll(JsPath path,
JsArray elems) |
Appends all the elements of the array, starting from the head, to the array located at the given
path in this json.
|
default T |
appendAllIfPresent(String path,
Supplier<JsArray> supplier) |
Appends all the elements of the array computed by the supplier, starting from the head, to an array
located at the path in this json, returning the same this instance if the array is not present,
in which case, the supplier is not invoked.
|
default T |
appendAllIfPresent(JsPath path,
Supplier<JsArray> supplier) |
Appends all the elements of the array computed by the supplier, starting from the head, to an
array located at the given path in this json, returning the same this instance if the array is
not present, in which case, the supplier is not invoked.
|
default T |
appendIfPresent(String path,
boolean bool,
boolean... others) |
Appends one or more booleans to the array located at the given path in this json, returning the
same this instance if the array is not present.
|
default T |
appendIfPresent(String path,
double number,
double... others) |
Appends one or more doubles to the array located at the given path in this json, returning the
same this instance if the array is not present.
|
default T |
appendIfPresent(String path,
int number,
int... others) |
Appends one or more integers to the array located at the given path in this json, returning the
same this instance if the array is not present.
|
default T |
appendIfPresent(String path,
long number,
long... others) |
Appends one or more longs to the array located at the given path in this json, returning the
same this instance if the array is not present.
|
default T |
appendIfPresent(String path,
String str,
String... others) |
Appends one or more strings to the array located at the given path in this json, returning the
same this instance if the array is not present.
|
default T |
appendIfPresent(String path,
Supplier<? extends JsElem> supplier) |
Appends the element given by the supplier, to the array located at the given path in this json,
returning the same this instance if the array is not present.
|
default T |
appendIfPresent(JsPath path,
boolean number,
boolean... others) |
Appends one or more booleans to the array located at the given path in this json, returning the
same this instance if the array is not present.
|
default T |
appendIfPresent(JsPath path,
double number,
double... others) |
Appends one or more doubles to the array located at the given path in this json, returning the
same this instance if the array is not present.
|
default T |
appendIfPresent(JsPath path,
int number,
int... others) |
Appends one or more integers to the array located at the given path in this json, returning the
same this instance if the array is not present.
|
default T |
appendIfPresent(JsPath path,
long number,
long... others) |
Appends one or more longs to the array located at the given path in this json, returning the
same this instance if the array is not present.
|
default T |
appendIfPresent(JsPath path,
String str,
String... others) |
Appends one or more strings to the array located at the given path in this json, returning the
same this instance if the array is not present.
|
default T |
appendIfPresent(JsPath path,
Supplier<? extends JsElem> supplier) |
Appends the element given by the supplier, to the array located at the given path in this json,
returning the same this instance if the array is not present.
|
boolean |
containsElem(JsElem element) |
Returns true if this json contains the given element in the first level.
|
default boolean |
containsElem_(JsElem element) |
Returns true if this json or any of its elements, contains the given element.
|
default boolean |
containsPath(String path) |
Returns true if an element exists in this json at the given path.
|
default boolean |
containsPath(JsPath path) |
Returns true if an element exists in this json at the given path.
|
default boolean |
equals(JsElem elem,
JsArray.TYPE ARRAY_AS) |
|
T |
filterElems(Predicate<? super JsPair> filter) |
Filters the pairs of elements in the first level of this json, removing those that don't match
the predicate.
|
T |
filterElems_(Predicate<? super JsPair> filter) |
Filters all the pairs of elements of this json, removing those that don't match the predicate.
|
T |
filterKeys(Predicate<? super JsPair> filter) |
Filters the keys in the first level parse this json, removing those that don't match the predicate.
|
T |
filterKeys_(Predicate<? super JsPair> filter) |
Filters all the keys parse this json, removing those that don't match the predicate.
|
T |
filterObjs(BiPredicate<? super JsPath,? super JsObj> filter) |
Filters the pair of jsons in the first level parse this json, removing those that don't match
the predicate.
|
T |
filterObjs_(BiPredicate<? super JsPath,? super JsObj> filter) |
Filters all the pair of jsons parse this json, removing those that don't match the predicate.
|
default JsElem |
get(String path) |
Returns the element located at the given path or
JsNothing if it doesn't exist. |
default JsElem |
get(JsPath path) |
Returns the element located at the given path or
JsNothing if it doesn't exist. |
JsElem |
get(Position position) |
Returns the element located at the key or index specified by the given position or
JsNothing if it
doesn't exist. |
default Optional<JsArray> |
getArray(String path) |
Returns the array located at the given path as a big decimal or
Optional.empty() if it
doesn't exist or it's not an array. |
default Optional<JsArray> |
getArray(JsPath path) |
Returns the array located at the given path or
Optional.empty() if it doesn't exist or
it's not an array. |
default Optional<BigDecimal> |
getBigDecimal(String path) |
Returns the big decimal located at the given path as a big decimal or
Optional.empty() if it
doesn't exist or it's not a decimal number. |
default Optional<BigDecimal> |
getBigDecimal(JsPath path) |
Returns the big decimal located at the given path as a big decimal or
Optional.empty() if
it doesn't exist or it's not a decimal number. |
default Optional<BigInteger> |
getBigInt(String path) |
Returns the big integer located at the given path as a big integer or
Optional.empty() if it
doesn't exist or it's not an integral number. |
default Optional<BigInteger> |
getBigInt(JsPath path) |
Returns the big integer located at the given path as a big integer or
Optional.empty() if it doesn't
exist or it's not an integral number. |
default Optional<Boolean> |
getBool(String path) |
Returns the boolean located at the given path or
Optional.empty() if it doesn't exist. |
default Optional<Boolean> |
getBool(JsPath path) |
Returns the boolean located at the given path or
Optional.empty() if it doesn't exist. |
default OptionalDouble |
getDouble(String path) |
Returns the decimal number located at the given path as a double or
OptionalDouble.empty() if it
doesn't exist or it's not a decimal number. |
default OptionalDouble |
getDouble(JsPath path) |
Returns the decimal number located at the given path as a double or
OptionalDouble.empty() if it
doesn't exist or it's not a decimal number. |
default OptionalInt |
getInt(String path) |
Returns the integral number located at the given path as an integer or
OptionalInt.empty() if it
doesn't exist or it's not an integral number or it's an integral number but doesn't fit in an integer. |
default OptionalInt |
getInt(JsPath path) |
Returns the integral number located at the given path as an integer or
OptionalInt.empty() if it
doesn't exist or it's not an integral number or it's an integral number but doesn't fit in an integer. |
default OptionalLong |
getLong(String path) |
Returns the integral number located at the given path as a long or
OptionalLong.empty() if it
doesn't exist or it's not an integral number or it's an integral number but doesn't fit in a long. |
default OptionalLong |
getLong(JsPath path) |
Returns the integral number located at the given path as a long or
OptionalLong.empty() if it
doesn't exist or it's not an integral number or it's an integral number but doesn't fit in a long. |
default Optional<JsObj> |
getObj(String path) |
Returns the object located at the given path or
Optional.empty() if it doesn't exist or it's
not an object. |
default Optional<JsObj> |
getObj(JsPath path) |
Returns the object located at the given path or
Optional.empty() if it doesn't exist or it's
not an object. |
default Optional<String> |
getStr(String path) |
Returns the string located at the given path or
Optional.empty() if it doesn't exist or it's
not an string. |
default Optional<String> |
getStr(JsPath path) |
Returns the string located at the given path or
Optional.empty() if it doesn't exist or it's
not an string. |
default <A> A |
ifEmptyElse(Supplier<A> emptySupplier,
Supplier<A> nonemptySupplier) |
Declarative way parse implementing if(this.isEmpty()) return emptySupplier.get() else return
nonEmptySupplier.get()
|
boolean |
isEmpty() |
return true if there's no element in this json
|
boolean |
isImmutable() |
|
boolean |
isMutable() |
|
default boolean |
isNotEmpty() |
return true if this json it not empty
|
default T |
map(Function<T,T> fn) |
|
T |
mapElems(Function<? super JsPair,? extends JsElem> fn) |
Maps the values in the first level parse this json.
|
T |
mapElems(Function<? super JsPair,? extends JsElem> fn,
Predicate<? super JsPair> predicate) |
Maps the values in the first level parse this json that satisfies a given predicate.
|
T |
mapElems_(Function<? super JsPair,? extends JsElem> fn) |
Maps all the values parse this json.
|
T |
mapElems_(Function<? super JsPair,? extends JsElem> fn,
Predicate<? super JsPair> predicate) |
Maps all the values parse this json that satisfies a given predicate.
|
T |
mapKeys(Function<? super JsPair,String> fn) |
Maps the keys in the first level parse this json.
|
T |
mapKeys(Function<? super JsPair,String> fn,
Predicate<? super JsPair> predicate) |
Maps the keys in the first level parse this json that satisfies a given predicate.
|
T |
mapKeys_(Function<? super JsPair,String> fn) |
Maps all the keys parse this json.
|
T |
mapKeys_(Function<? super JsPair,String> fn,
Predicate<? super JsPair> predicate) |
Maps all the keys parse this json that satisfies a given predicate.
|
T |
mapObjs(BiFunction<? super JsPath,? super JsObj,JsObj> fn) |
Maps the jsons in the first level parse this json.
|
T |
mapObjs(BiFunction<? super JsPath,? super JsObj,JsObj> fn,
BiPredicate<? super JsPath,? super JsObj> predicate) |
Maps the jsons in the first level parse this json that satisfies a given predicate.
|
T |
mapObjs_(BiFunction<? super JsPath,? super JsObj,JsObj> fn) |
Maps all the jsons parse this json.
|
T |
mapObjs_(BiFunction<? super JsPath,? super JsObj,JsObj> fn,
BiPredicate<? super JsPath,? super JsObj> predicate) |
Maps all the jsons parse this json that satisfies a given predicate.
|
default T |
merge(String path,
JsElem value,
BiFunction<? super JsElem,? super JsElem,? extends JsElem> fn) |
If the given path is not already associated with a value or is associated with null, associates it with the given value.
|
default T |
merge(JsPath path,
JsElem value,
BiFunction<? super JsElem,? super JsElem,? extends JsElem> fn) |
If the given path is not already associated with a value or is associated with null, associates it with the given value.
|
static Try |
parse(String str) |
Tries to parse the string into an immutable json.
|
static Try |
parse(String str,
ParseOptions options) |
Tries to parse the string into an immutable json, performing some operations while the parsing.
|
default T |
prepend(String path,
boolean elem,
boolean... others) |
Prepends one or more booleans, starting from the first, to the array located at the path in this
json.
|
default T |
prepend(String path,
double elem,
double... others) |
Prepends one or more doubles, starting from the first, to the array located at the path in this
json.
|
default T |
prepend(String path,
int elem,
int... others) |
Prepends one or more integers, starting from the first, to the array located at the path in this
json.
|
default T |
prepend(String path,
long elem,
long... others) |
Prepends one or more longs, starting from the first, to the array located at the path in this
json.
|
default T |
prepend(String path,
String elem,
String... others) |
Prepends one or more strings, starting from the first, to the array located at the path in this
json.
|
default T |
prepend(String path,
JsElem elem) |
prepends one element to the array located at the path in this json.
|
default T |
prepend(String path,
JsElem elem,
JsElem... others) |
Prepends one or more elements, starting from the first, to the array located at the path in this
json.
|
default T |
prepend(JsPath path,
boolean elem,
boolean... others) |
prepends one or more booleans, starting from the first, to the array located at the path in this
json.
|
default T |
prepend(JsPath path,
double elem,
double... others) |
prepends one or more doubles, starting from the first, to the array located at the path in this
json.
|
default T |
prepend(JsPath path,
int elem,
int... others) |
prepends one or more integers, starting from the first, to the array located at the path in this
json.
|
default T |
prepend(JsPath path,
long elem,
long... others) |
prepends one or more longs, starting from the first, to the array located at the path in this
json.
|
default T |
prepend(JsPath path,
String elem,
String... others) |
Prepends one or more strings, starting from the first, to the array located at the path in this
json.
|
T |
prepend(JsPath path,
JsElem elem) |
prepends one element to the array located at the path in this json.
|
default T |
prepend(JsPath path,
JsElem elem,
JsElem... others) |
prepends one or more elements, starting from the first, to the array located at the path in this
json.
|
default T |
prependAll(String path,
JsArray elems) |
prepends all the elements of the array, starting from the head, to the array located at the path
in this json.
|
T |
prependAll(JsPath path,
JsArray elems) |
prepends all the elements of the array, starting from the head, to the array located at the path
in this json.
|
default T |
prependAllIfPresent(String path,
Supplier<JsArray> supplier) |
Prepends all the elements of the array computed by the supplier, starting from the head, to the
array located at the path in this json, returning the same this instance if the array is not present,
in which case, the supplier is not invoked.
|
default T |
prependAllIfPresent(JsPath path,
Supplier<JsArray> supplier) |
Prepends all the elements of the array computed by the supplier, starting from the head, to the
array located at the path in this json, returning the same this instance if the array is not present,
in which case, the supplier is not invoked.
|
default T |
prependIfPresent(String path,
boolean bool,
boolean... others) |
Prepends one or more booleans to the array located at the given path in this json in the following
order [number, others, existing elements], returning the same this instance if the array is not present.
|
default T |
prependIfPresent(String path,
double number,
double... others) |
Prepends one or more doubles to the array located at the given path in this json in the following
order [number, others, existing elements], returning the same this instance if the array is not present.
|
default T |
prependIfPresent(String path,
int number,
int... others) |
Prepends one or more integers to the array located at the given path in this json in the following
order [number, others, existing elements], returning the same this instance if the array is not present.
|
default T |
prependIfPresent(String path,
long number,
long... others) |
Prepends one or more strings to the array located at the given path in this json in the following
order [number, others, existing elements], returning the same this instance if the array is not present.
|
default T |
prependIfPresent(String path,
String str,
String... others) |
Prepends one or more strings to the array located at the given path in this json in the following
order [number, others, existing elements], returning the same this instance if the array is not present.
|
default T |
prependIfPresent(String path,
Supplier<JsElem> supplier) |
Prepends one element given by a supplier, to the array located at the given path in this json,
returning the same this instance if the array is not present.
|
default T |
prependIfPresent(JsPath path,
boolean bool,
boolean... others) |
Prepends one or more booleans to the array located at the given path in this json in the following
order [number, others, existing elements], returning the same this instance if the array is not present.
|
default T |
prependIfPresent(JsPath path,
double number,
double... others) |
Prepends one or more doubles to the array located at the given path in this json in the following
order [number, others, existing elements], returning the same this instance if the array is not present.
|
default T |
prependIfPresent(JsPath path,
int number,
int... others) |
Prepends one or more integers to the array located at the given path in this json in the following
order [number, others, existing elements], returning the same this instance if the array is not present.
|
default T |
prependIfPresent(JsPath path,
long number,
long... others) |
Prepends one or more longs to the array located at the given path in this json in the following
order [number, others, existing elements], returning the same this instance if the array is not present.
|
default T |
prependIfPresent(JsPath path,
String str,
String... others) |
Prepends one or more strings to the array located at the given path in this json in the following
order [number, others, existing elements], returning the same this instance if the array is not present.
|
default T |
prependIfPresent(JsPath path,
Supplier<JsElem> supplier) |
Prepends one element given by a supplier, to the array located at the given path in this json,
returning the same this instance if the array is not present.
|
default T |
put(String path,
boolean bool) |
Inserts the boolean at the given path in this json, replacing any existing element in the path
and filling with
JsNull empty positions in arrays when necessary. |
default T |
put(String path,
int n) |
Inserts the integer number at the path in this json, replacing any existing element and filling with
JsNull
empty indexes in arrays when necessary. |
default T |
put(String path,
long n) |
Inserts the long number at the path in this json, replacing any existing element and filling with
JsNull
empty indexes in arrays when necessary. |
default T |
put(String path,
String str) |
Inserts the string at the given path in this json, replacing any existing element in the path
and filling with
JsNull empty positions in arrays when necessary. |
default T |
put(String path,
BigDecimal bigdecimal) |
Inserts the big decimal number at the given path in this json, replacing any existing element in
the path and filling with
JsNull empty positions in arrays when necessary. |
default T |
put(String path,
BigInteger bigint) |
Inserts the big integer number at the given path in this json, replacing any existing element
in teh path and filling with
JsNull empty positions in arrays when necessary. |
default T |
put(String path,
Function<? super JsElem,? extends JsElem> fn) |
Inserts the element returned by the function at the path in this json, replacing any existing
element in the path and filling with
JsNull empty indexes in arrays when
necessary. |
default T |
put(String path,
JsElem element) |
Inserts the element at the path in this json, replacing any existing element and filling with
JsNull empty
indexes in arrays when necessary. |
T |
put(JsPath path,
Function<? super JsElem,? extends JsElem> fn) |
Inserts the element returned by the function at the path in this json, replacing any existing element and filling with
JsNull empty indexes in arrays when necessary. |
default T |
put(JsPath path,
JsElem element) |
Inserts the element at the path in this json, replacing any existing element and filling with
JsNull empty
indexes in arrays when necessary. |
default T |
putIf(Predicate<? super JsElem> predicate,
String path,
Function<? super JsElem,? extends JsElem> fn) |
Inserts at the given path in this json, if the existing element satisfies the predicate, a new
element returned by the function.
|
default T |
putIf(Predicate<? super JsElem> predicate,
JsPath path,
Function<? super JsElem,? extends JsElem> fn) |
Inserts at the given path in this json, if the existing element satisfies the predicate, a new
element returned by the function.
|
default T |
putIfAbsent(String path,
double number) |
Inserts at the given path in this json, if no element is present, the specified double, replacing
any existing element in the path and filling with
JsNull empty positions in
arrays when necessary. |
default T |
putIfAbsent(String path,
int number) |
Inserts at the given path in this json, if no element is present, the specified integer, replacing
any existing element in the path and filling with
JsNull empty positions in
arrays when necessary. |
default T |
putIfAbsent(String path,
long number) |
Inserts at the given path in this json, if no element is present, the specified long, replacing
any existing element in the path and filling with
JsNull empty positions in
arrays when necessary. |
default T |
putIfAbsent(String path,
Supplier<? extends JsElem> supplier) |
Inserts at the given path in this json, if no element is present, the element returned by the
supplier, replacing any existing element in the path and filling with
JsNull
empty positions in arrays when necessary. |
default T |
putIfAbsent(JsPath path,
double number) |
Inserts at the given path in this json, if no element is present, the specified double, replacing
any existing element in the path and filling with
JsNull empty positions in
arrays when necessary. |
default T |
putIfAbsent(JsPath path,
int number) |
Inserts at the given path in this json, if no element is present, the specified integer, replacing
any existing element in the path and filling with
JsNull empty positions in
arrays when necessary. |
default T |
putIfAbsent(JsPath path,
long number) |
Inserts at the given path in this json, if no element is present, the specified long, replacing
any existing element in the path and filling with
JsNull empty positions in
arrays when necessary. |
default T |
putIfAbsent(JsPath path,
Supplier<? extends JsElem> supplier) |
Inserts at the given path in this json, if no element is present, the element returned by the
supplier, replacing any existing element in the path and filling with
JsNull
empty positions in arrays when necessary. |
default T |
putIfPresent(String path,
double number) |
Inserts at the given path in this json, if some element is present, the specified double.
|
default T |
putIfPresent(String path,
int number) |
Inserts at the given path in this json, if some element is present, the specified integer.
|
default T |
putIfPresent(String path,
long number) |
Inserts at the given path in this json, if some element is present, the specified long.
|
default T |
putIfPresent(String path,
Function<? super JsElem,? extends JsElem> fn) |
Inserts at the given path in this json, if some element is present, the element returned by the
function.
|
default T |
putIfPresent(JsPath path,
double number) |
Inserts at the given path in this json, if some element is present, the specified double.
|
default T |
putIfPresent(JsPath path,
int number) |
Inserts at the given path in this json, if some element is present, the specified integer.
|
default T |
putIfPresent(JsPath path,
long number) |
Inserts at the given path in this json, if some element is present, the specified long.
|
default T |
putIfPresent(JsPath path,
Function<? super JsElem,? extends JsElem> fn) |
Inserts at the given path in this json, if some element is present, the element returned by the
function.
|
<R> Optional<R> |
reduce(BinaryOperator<R> op,
Function<? super JsPair,R> map,
Predicate<? super JsPair> predicate) |
Performs a reduction on the values that satisfy the predicate in the first level of this json.
|
<R> Optional<R> |
reduce_(BinaryOperator<R> op,
Function<? super JsPair,R> map,
Predicate<? super JsPair> predicate) |
Performs a reduction on the values of this json that satisfy the predicate.
|
default T |
remove(String path) |
Removes the element in this json located at the given path, if it exists, returning the same this
instance otherwise
|
T |
remove(JsPath path) |
Removes the element in this json located at the given path, if it exists, returning the same this
instance otherwise
|
int |
size() |
Returns the number of elements in the first level of this json
|
default OptionalInt |
size(String path) |
Returns the size of the json located at the given path in this json or OptionalInt.empty() if it
doesn't exist or it's not a Json
|
default OptionalInt |
size(JsPath path) |
Returns the size of the json located at the given path in this json or OptionalInt.empty() if it
doesn't exist or it's not a Json
|
default int |
size_() |
Returns the number of all the elements in this json
|
default OptionalInt |
size_(String path) |
Returns the size of the Json located at the given path in this json or OptionalInt.empty() if it
doesn't exist or it's not a Json
|
default OptionalInt |
size_(JsPath path) |
Returns the size of the json located at the given path in this json or OptionalInt.empty() if it
doesn't exist or it's not a Json
|
Stream<JsPair> |
stream() |
Returns a stream over the pairs of elements in the first level of this json object.
|
Stream<JsPair> |
stream_() |
Returns a stream over all the pairs of elements in this json object.
|
default long |
times(JsElem e) |
|
default long |
times_(JsElem e) |
|
T |
toImmutable() |
Converts this json into immutable if it's mutable, returning this same instance otherwise.
|
T |
toMutable() |
Converts this json into mutable if it's immutable, returning this same instance otherwise.
|
asJsArray, asJsBigDec, asJsBigInt, asJsBool, asJsDouble, asJsInt, asJsLong, asJsObj, asJson, asJsStr, isArray, isArray, isBigDec, isBigDec, isBigInt, isBigInt, isBool, 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
static final long serialVersionUID
static Try _parse_(String str)
str
- the string to be parsedTry
computationstatic Try _parse_(String str, ParseOptions options)
str
- the string that will be parsed.options
- a builder with the filters and maps that, if specified, will be applied during the parsingTry
computationT appendAll(JsPath path, JsArray elems)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given JsPath pointing to the array in which all the elements will be appendedelems
- the JsArray of elements to be appendeddefault T appendAll(String path, JsArray elems)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path-like string pointing to the array in which all the elements will be appendedelems
- the JsArray of elements to be appended to the existing or created arraydefault T append(JsPath path, JsElem elem, JsElem... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given JsPath pointing to the array in which all the elements will be appendedelem
- the first JsElem to be appended to the existing or created arrayothers
- more optional JsElem to be appendeddefault T append(String path, JsElem elem, JsElem... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path-like string pointing to the array in which all the elements will be appendedelem
- the first JsElem to be appended to the existing or created arrayothers
- more optional JsElem to be appendeddefault T append(String path, JsElem elem)
JsNull
when necessary. The same this instance is returned when it's an array
and the head of the path is a key or when it's an object and the head of the path is an index.path
- the given path-like string pointing to the array in which the element will be appendedelem
- the JsElem to be appended to the existing or created arrayT append(JsPath path, JsElem elem)
JsNull
when necessary. The same this instance is returned when it's an array
and the head of the path is a key or when it's an object and the head of the path is an index.path
- the path pointing to the array in which the element will be appendedelem
- the JsElem to be appended to the existing or created arraydefault T appendIfPresent(String path, Supplier<? extends JsElem> supplier)
path
- the path-like string pointing to the existing array in which the element will be appendedsupplier
- the given supplierdefault T appendIfPresent(JsPath path, Supplier<? extends JsElem> supplier)
path
- the JsPath pointing to the existing array in which the element will be appendedsupplier
- the given supplierdefault T appendAllIfPresent(JsPath path, Supplier<JsArray> supplier)
path
- the given JsPath object pointing to the existing array in which all the elements will be appendedsupplier
- the supplier of the array of elements that will be appendeddefault T appendAllIfPresent(String path, Supplier<JsArray> supplier)
path
- the path-like string pointing to the existing array in which all the elements will be appendedsupplier
- the supplier of the array of elements that will be appendedT prependAll(JsPath path, JsArray elems)
JsNull
when
necessary. The same this instance is returned when it's an array and the head of the path is
a key or when it's an object and the head of the path is an index.path
- the JsPath pointing to the array in which all the elements will be prependedelems
- the JsArray of elements to be prepended to the existing or created arraydefault T prependAll(String path, JsArray elems)
JsNull
when
necessary. The same this instance is returned when it's an array and the head of the path is
a key or when it's an object and the head of the path is an index.path
- the path-like string pointing to the array in which all the elements will be prependedelems
- the JsArray of elements to be prepended to the existing or created arraydefault T prepend(JsPath path, JsElem elem, JsElem... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the JsPath pointing to the array in which all the elements will be prependedelem
- the first JsElem to be prepended to the existing or created arrayothers
- more optional JsElem to be prependedT prepend(JsPath path, JsElem elem)
JsNull
when necessary. The same this instance is returned when it's
an array and the head of the path is a key or when it's an object and the head of the path is an index.path
- the JsPath pointing to the array in which the element will be prependedelem
- the JsElem to be prepended to the existing or created arraydefault T prepend(String path, JsElem elem)
JsNull
when necessary. The same this instance is returned when it's
an array and the head of the path is a key or when it's an object and the head of the path is an index.path
- the path-like string pointing to the array in which the element will be prependedelem
- the JsElem to be prepended to the existing or created arraydefault T prepend(String path, JsElem elem, JsElem... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the path-like string pointing to the array in which all the elements will be prependedelem
- the first JsElem to be prepended to the existing or created arrayothers
- more optional JsElem to be prependeddefault T prependAllIfPresent(JsPath path, Supplier<JsArray> supplier)
path
- the JsPath object pointing to the existing array in which all the elements will be prependedsupplier
- the supplier of the array of elements that will be prependeddefault T prependAllIfPresent(String path, Supplier<JsArray> supplier)
path
- the path-like string pointing to the existing array in which all the elements will be prependedsupplier
- the supplier of the array of elements that will be prependeddefault T prependIfPresent(String path, Supplier<JsElem> supplier)
path
- the JsPath pointing to the existing array in which all the elements will be appendedsupplier
- the given supplierdefault T prependIfPresent(String path, String str, String... others)
path
- the path-like string pointing to the existing array in which the strings will be prependedstr
- the string to be prependedothers
- more optional strings to be prependeddefault T prependIfPresent(String path, int number, int... others)
path
- the path-like string pointing to the existing array in which the integers will be prependednumber
- the integer to be prependedothers
- more optional integers to be prependeddefault T prependIfPresent(String path, long number, long... others)
path
- the path-like string pointing to the existing array in which the strings will be prependednumber
- the string to be prependedothers
- more optional strings to be prependeddefault T prependIfPresent(String path, double number, double... others)
path
- the path-like string pointing to the existing array in which the doubles will be prependednumber
- the double to be prependedothers
- more optional doubles to be prependeddefault T prependIfPresent(String path, boolean bool, boolean... others)
path
- the path-like string pointing to the existing array in which the booleans will be prependedbool
- the boolean to be prependedothers
- more optional booleans to be prependeddefault T prependIfPresent(JsPath path, Supplier<JsElem> supplier)
path
- the JsPath pointing to the existing array in which all the elements will be appendedsupplier
- the given supplierdefault T prependIfPresent(JsPath path, int number, int... others)
path
- the path pointing to the existing array in which the integers will be prependednumber
- the integer to be prependedothers
- more optional integers to be prependeddefault T prependIfPresent(JsPath path, long number, long... others)
path
- the path pointing to the existing array in which the longs will be prependednumber
- the long to be prependedothers
- more optional longs to be prependeddefault T prependIfPresent(JsPath path, double number, double... others)
path
- the path pointing to the existing array in which the doubles will be prependednumber
- the double to be prependedothers
- more optional doubles to be prependeddefault T prependIfPresent(JsPath path, String str, String... others)
path
- the path pointing to the existing array in which the strings will be prependedstr
- the string to be prependedothers
- more optional strings to be prependeddefault T prependIfPresent(JsPath path, boolean bool, boolean... others)
path
- the path pointing to the existing array in which the booleans will be prependedbool
- the boolean to be prependedothers
- more optional booleans to be prependedT filterElems(Predicate<? super JsPair> filter)
filter
- the predicate which takes as the input every JsPair in the first level parse this jsonhow to filter the pair of elements of the whole json and not only the first level
T filterElems_(Predicate<? super JsPair> filter)
filter
- the predicate which takes as the input every JsPair of this jsonhow to filter the pairs of values parse only the first level
T filterObjs(BiPredicate<? super JsPath,? super JsObj> filter)
filter
- the predicate which takes as the input every JsPair in the first level parse this jsonhow to filter the pair of jsons of the whole json and not only the first level
T filterObjs_(BiPredicate<? super JsPath,? super JsObj> filter)
filter
- the predicate which takes as the input every JsPair of this jsonhow to filter the pair of jsons parse only the first level
T filterKeys(Predicate<? super JsPair> filter)
filter
- the predicate which takes as the input every JsPair in the first level parse this jsonhow to filter the keys of the whole json and not only the first level
T filterKeys_(Predicate<? super JsPair> filter)
filter
- the predicate which takes as the input every JsPair of this jsonhow to filter the keys of only the first level
JsElem get(Position position)
JsNothing
if it
doesn't exist.position
- key or index of the elementdefault JsElem get(JsPath path)
JsNothing
if it doesn't exist.path
- the JsPath object of the element that will be returneddefault JsElem get(String path)
JsNothing
if it doesn't exist.path
- the path-like string of the element that will be returneddefault Optional<JsArray> getArray(JsPath path)
Optional.empty()
if it doesn't exist or
it's not an array.path
- the JsPath object of the JsArray that will be returneddefault Optional<JsArray> getArray(String path)
Optional.empty()
if it
doesn't exist or it's not an array.path
- the path-like string of the JsArray that will be returneddefault Optional<BigDecimal> getBigDecimal(JsPath path)
Optional.empty()
if
it doesn't exist or it's not a decimal number.path
- the JsPath object of the BigDecimal that will be returneddefault Optional<BigDecimal> getBigDecimal(String path)
Optional.empty()
if it
doesn't exist or it's not a decimal number.path
- the path-like string of the BigDecimal that will be returneddefault Optional<BigInteger> getBigInt(JsPath path)
Optional.empty()
if it doesn't
exist or it's not an integral number.path
- the JsPath object of the BigInteger that will be returneddefault Optional<BigInteger> getBigInt(String path)
Optional.empty()
if it
doesn't exist or it's not an integral number.path
- the path-like string of the BigInteger that will be returneddefault Optional<Boolean> getBool(JsPath path)
Optional.empty()
if it doesn't exist.path
- the JsPath object of the Boolean that will be returneddefault Optional<Boolean> getBool(String path)
Optional.empty()
if it doesn't exist.path
- the path-like string of the Boolean that will be returneddefault OptionalDouble getDouble(JsPath path)
OptionalDouble.empty()
if it
doesn't exist or it's not a decimal number. If the number is a BigDecimal, the conversion is identical
to the specified in BigDecimal.doubleValue()
and in some cases it can lose information about
the precision of the BigDecimalpath
- the JsPath object of the double that will be returneddefault OptionalDouble getDouble(String path)
OptionalDouble.empty()
if it
doesn't exist or it's not a decimal number. If the number is a BigDecimal, the conversion is
identical to the specified in BigDecimal.doubleValue()
and in some cases it can lose information
about the precision of the BigDecimalpath
- the path-like string of the decimal number that will be returneddefault OptionalInt getInt(JsPath path)
OptionalInt.empty()
if it
doesn't exist or it's not an integral number or it's an integral number but doesn't fit in an integer.path
- the JsPath object of the integral number that will be returneddefault OptionalInt getInt(String path)
OptionalInt.empty()
if it
doesn't exist or it's not an integral number or it's an integral number but doesn't fit in an integer.path
- the path-like string of the integral number that will be returneddefault OptionalLong getLong(JsPath path)
OptionalLong.empty()
if it
doesn't exist or it's not an integral number or it's an integral number but doesn't fit in a long.path
- the JsPath object of the integral number that will be returneddefault OptionalLong getLong(String path)
OptionalLong.empty()
if it
doesn't exist or it's not an integral number or it's an integral number but doesn't fit in a long.path
- the path-like string of the integral number that will be returneddefault Optional<JsObj> getObj(JsPath path)
Optional.empty()
if it doesn't exist or it's
not an object.path
- the JsPath object of the JsObj that will be returneddefault Optional<JsObj> getObj(String path)
Optional.empty()
if it doesn't exist or it's
not an object.path
- the path-like string of the JsObj that will be returneddefault Optional<String> getStr(JsPath path)
Optional.empty()
if it doesn't exist or it's
not an string.path
- the JsPath object of the JsStr that will be returneddefault Optional<String> getStr(String path)
Optional.empty()
if it doesn't exist or it's
not an string.path
- the path-like string of the JsStr that will be returneddefault <A> A ifEmptyElse(Supplier<A> emptySupplier, Supplier<A> nonemptySupplier)
A
- the type of the resultemptySupplier
- Supplier that will produce the result if this json is emptynonemptySupplier
- Supplier that will produce the result if this json is not emptydefault long times(JsElem e)
default long times_(JsElem e)
default boolean equals(JsElem elem, JsArray.TYPE ARRAY_AS)
boolean isEmpty()
default boolean isNotEmpty()
T mapElems(Function<? super JsPair,? extends JsElem> fn)
fn
- the mapping functionto map jsons
,
to map keys parse json objects
,
to map all the values and not only the first level
T mapElems(Function<? super JsPair,? extends JsElem> fn, Predicate<? super JsPair> predicate)
fn
- the mapping functionpredicate
- the given predicate that determines what JsValues will be mappedto map jsons
,
to map keys parse json objects
,
to map all the values and not only the first level
T mapElems_(Function<? super JsPair,? extends JsElem> fn)
fn
- the mapping functionto map jsons
,
to map keys parse json objects
,
to map only the first level
T mapElems_(Function<? super JsPair,? extends JsElem> fn, Predicate<? super JsPair> predicate)
fn
- the mapping functionpredicate
- the given predicate that determines what JsValues will be mappedto map jsons
,
to map keys parse json objects
,
to map only the first level
T mapObjs(BiFunction<? super JsPath,? super JsObj,JsObj> fn, BiPredicate<? super JsPath,? super JsObj> predicate)
fn
- the mapping functionpredicate
- the given predicate that determines what Jsons will be mappedto map values
,
to map keys parse json objects
,
to map all the jsons and not only the first level
T mapObjs(BiFunction<? super JsPath,? super JsObj,JsObj> fn)
fn
- the mapping functionto map values
,
to map keys parse json objects
,
to map all the jsons and not only the first level
T mapObjs_(BiFunction<? super JsPath,? super JsObj,JsObj> fn, BiPredicate<? super JsPath,? super JsObj> predicate)
fn
- the mapping functionpredicate
- the given predicate that determines what Jsons will be mappedto map values
,
to map keys parse json objects
,
to map only the first level
T mapObjs_(BiFunction<? super JsPath,? super JsObj,JsObj> fn)
fn
- the mapping functionto map values
,
to map keys parse json objects
,
to map only the first level
T mapKeys(Function<? super JsPair,String> fn)
fn
- the mapping functionto map values
,
to map jsons
,
to map all the keys and not only the first level
T mapKeys(Function<? super JsPair,String> fn, Predicate<? super JsPair> predicate)
fn
- the mapping functionpredicate
- the given predicate that determines what keys will be mappedto map jsons
,
to map values
,
to map all the keys and not only the first level
T mapKeys_(Function<? super JsPair,String> fn)
fn
- the mapping functionto map values
,
to map jsons
,
to map only the first level
T mapKeys_(Function<? super JsPair,String> fn, Predicate<? super JsPair> predicate)
fn
- the mapping functionpredicate
- the given predicate that determines what keys will be mappedto map values
,
to map jsons
,
to map only the first level
default T merge(JsPath path, JsElem value, BiFunction<? super JsElem,? super JsElem,? extends JsElem> fn)
map.merge(key, msg, String::concat)
path
- the given JsPath object which the resulting value is to be associatedvalue
- the given value to be merged with the existing value associated with the path or, if no existing value or a null value is
associated with the path, to be associated with the pathfn
- the given function to recompute a value if presentdefault T merge(String path, JsElem value, BiFunction<? super JsElem,? super JsElem,? extends JsElem> fn)
map.merge(key, msg, String::concat)
path
- the given path-like string which the resulting value is to be associatedvalue
- the given value to be merged with the existing value associated with the path or, if no existing value or a null value is
associated with the path, to be associated with the pathfn
- the given function to recompute a value if presentstatic Try parse(String str)
str
- the string that will be parsedTry
computationstatic Try parse(String str, ParseOptions options)
str
- the string that will be parsedoptions
- a Options with the filters and maps that will be applied during the parsingTry
computationT put(JsPath path, Function<? super JsElem,? extends JsElem> fn)
JsNull
empty indexes in arrays when necessary.
The same instance is returned when the head of the path is a key and this is an array or the head of the path is an index and this is an object. In both cases the function is not invoked.
The same instance is returned as well when the element returned by the function is JsNothing
path
- the JsPath object where the JsElem will be inserted atfn
- the function that takes as an input the JsElem at the path and produces the JsElem to be inserted at the pathdefault T put(String path, Function<? super JsElem,? extends JsElem> fn)
JsNull
empty indexes in arrays when
necessary. The same instance is returned if the path doesn't exist. In both cases the function
is not invoked. The same instance is returned when the element returned by the function is
JsNothing
path
- the path-like string where the JsElem will be inserted atfn
- the function that takes as an input the JsElem at the path and produces the JsElem to be inserted at the pathdefault T put(JsPath path, JsElem element)
JsNull
empty
indexes in arrays when necessary.
The same instance is returned when the head of the path is a key and this is an array or the head
of the path is an index and this is an object or the element is JsNothing
path
- the JsPath object where the element will be inserted atelement
- the JsElem that will be inserteddefault T put(String path, JsElem element)
JsNull
empty
indexes in arrays when necessary.
The same instance is returned when the head of the path is a key and this is an array or the
head of the path is an index and this is an object or the element is JsNothing
path
- the path-like string where the element will be inserted atelement
- the JsElem that will be inserteddefault T put(String path, int n)
JsNull
empty indexes in arrays when necessary. The same instance is returned when the head of the path
is a key and this is an array or the head of the path is an index and this is an object or the
element is JsNothing
path
- the path-like string where the integer number will be inserted atn
- the integer that will be inserteddefault T put(String path, long n)
JsNull
empty indexes in arrays when necessary. The same instance is returned when the head of the path
is a key and this is an array or the head of the path is an index and this is an object or the
element is JsNothing
path
- the path-like string where the long number will be inserted atn
- the long number that will be inserteddefault T put(String path, String str)
JsNull
empty positions in arrays when necessary.path
- the path-like string where the string will be inserted atstr
- the string that will be inserteddefault T put(String path, BigInteger bigint)
JsNull
empty positions in arrays when necessary.path
- the given path-like string where the big integer number will be inserted atbigint
- the big integer number that will be inserteddefault T put(String path, BigDecimal bigdecimal)
JsNull
empty positions in arrays when necessary.path
- the given path-like string where the big decimal number will be inserted atbigdecimal
- the big decimal number that will be inserteddefault T put(String path, boolean bool)
JsNull
empty positions in arrays when necessary.path
- the given path-like string where the boolean will be inserted atbool
- the boolean that will be inserteddefault T putIf(Predicate<? super JsElem> predicate, JsPath path, Function<? super JsElem,? extends JsElem> fn)
JsNothing
,
the same this instance is returned.predicate
- the predicate on which the existing element is tested onpath
- the JsPath objectfn
- the function witch computes the new element if the existing one satisfies the given predicatedefault T putIf(Predicate<? super JsElem> predicate, String path, Function<? super JsElem,? extends JsElem> fn)
JsNothing
,
the same this instance is returned.predicate
- the predicate on which the existing element is tested onpath
- the path-like stringfn
- the function witch computes the new element if the existing satisfies the given predicatedefault T putIfAbsent(JsPath path, Supplier<? extends JsElem> supplier)
JsNull
empty positions in arrays when necessary. The supplier is not invoked if the element is present.path
- the given JsPath objectsupplier
- the supplier which computes the new JsElem if absentdefault T putIfAbsent(JsPath path, int number)
JsNull
empty positions in
arrays when necessary.path
- the given JsPath objectnumber
- the specified integerdefault T putIfAbsent(JsPath path, long number)
JsNull
empty positions in
arrays when necessary.path
- the given JsPath objectnumber
- the specified longdefault T putIfAbsent(JsPath path, double number)
JsNull
empty positions in
arrays when necessary.path
- the given JsPath objectnumber
- the specified doubledefault T putIfAbsent(String path, int number)
JsNull
empty positions in
arrays when necessary.path
- the path-like stringnumber
- the specified integerdefault T putIfAbsent(String path, long number)
JsNull
empty positions in
arrays when necessary.path
- the path-like stringnumber
- the specified longdefault T putIfAbsent(String path, double number)
JsNull
empty positions in
arrays when necessary.path
- the path-like stringnumber
- the specified doubledefault T putIfPresent(JsPath path, int number)
path
- the given pathnumber
- the specified integerdefault T putIfPresent(JsPath path, long number)
path
- the given pathnumber
- the specified longdefault T putIfPresent(JsPath path, double number)
path
- the given pathnumber
- the specified doubledefault T putIfPresent(String path, int number)
path
- the given path-like stringnumber
- the specified integerdefault T putIfPresent(String path, long number)
path
- the given path-like stringnumber
- the specified longdefault T putIfPresent(String path, double number)
path
- the given path-like stringnumber
- the specified doubledefault T appendIfPresent(JsPath path, int number, int... others)
path
- the path pointing to the existing array in which the integers will be appendednumber
- the integer to be appendedothers
- more optional integers to be appendeddefault T appendIfPresent(JsPath path, long number, long... others)
path
- the path pointing to the existing array in which the longs will be appendednumber
- the long to be appendedothers
- more optional longs to be appendeddefault T appendIfPresent(JsPath path, String str, String... others)
path
- the path pointing to the existing array in which the strings will be appendedstr
- the string to be appendedothers
- more optional strings to be appendeddefault T appendIfPresent(JsPath path, boolean number, boolean... others)
path
- the path pointing to the existing array in which the booleans will be appendednumber
- the boolean to be appendedothers
- more optional booleans to be appendeddefault T appendIfPresent(JsPath path, double number, double... others)
path
- the path pointing to the existing array in which the doubles will be appendednumber
- the double to be appendedothers
- more optional doubles to be appendeddefault T appendIfPresent(String path, int number, int... others)
path
- the path-like string pointing to the existing array in which the integers will be appendednumber
- the integer to be appendedothers
- more optional integers to be appendeddefault T appendIfPresent(String path, long number, long... others)
path
- the path-like string pointing to the existing array in which the longs will be appendednumber
- the long to be appendedothers
- more optional longs to be appendeddefault T appendIfPresent(String path, String str, String... others)
path
- the path-like string pointing to the existing array in which the strings will be appendedstr
- the string to be appendedothers
- more optional strings to be appendeddefault T appendIfPresent(String path, boolean bool, boolean... others)
path
- the path-like string pointing to the existing array in which the booleans will be appendedbool
- the boolean to be appendedothers
- more optional booleans to be appendeddefault T appendIfPresent(String path, double number, double... others)
path
- the path-like string pointing to the existing array in which the doubles will be appendednumber
- the double to be appendedothers
- more optional doubles to be appendeddefault T append(String path, String elem, String... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path-like string pointing to the array in which all the strings will be appendedelem
- the first string to be appended to the existing or created arrayothers
- more optional strings to be appendeddefault T append(String path, int elem, int... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path-like string pointing to the array in which all the integers will be appendedelem
- the first integer to be appended to the existing or created arrayothers
- more optional integers to be appendeddefault T append(String path, long elem, long... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path-like string pointing to the array in which all the longs will be appendedelem
- the first long to be appended to the existing or created arrayothers
- more optional longs to be appendeddefault T append(String path, boolean elem, boolean... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path-like string pointing to the array in which all the booleans will be appendedelem
- the first boolean to be appended to the existing or created arrayothers
- more optional booleans to be appendeddefault T append(String path, double elem, double... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path-like string pointing to the array in which all the doubles will be appendedelem
- the first double to be appended to the existing or created arrayothers
- more optional doubles to be appendeddefault T append(JsPath path, String elem, String... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path pointing to the array in which all the strings will be appendedelem
- the first string to be appended to the existing or created arrayothers
- more optional strings to be appendeddefault T append(JsPath path, int elem, int... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path pointing to the array in which all the integers will be appendedelem
- the first integer to be appended to the existing or created arrayothers
- more optional integers to be appendeddefault T append(JsPath path, long elem, long... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path pointing to the array in which all the longs will be appendedelem
- the first long to be appended to the existing or created arrayothers
- more optional longs to be appendeddefault T append(JsPath path, boolean elem, boolean... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path pointing to the array in which all the booleans will be appendedelem
- the first boolean to be appended to the existing or created arrayothers
- more optional booleans to be appendeddefault T append(JsPath path, double elem, double... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the given path pointing to the array in which all the doubles will be appendedelem
- the first double to be appended to the existing or created arrayothers
- more optional doubles to be appendeddefault T prepend(String path, String elem, String... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the path-like string pointing to the array in which all the string will be prependedelem
- the first string to be prepended to the existing or created arrayothers
- more optional strings to be prependeddefault T prepend(String path, int elem, int... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the path-like string pointing to the array in which all the string will be prependedelem
- the first integer to be prepended to the existing or created arrayothers
- more optional integers to be prependeddefault T prepend(String path, long elem, long... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the path-like string pointing to the array in which all the string will be prependedelem
- the first long to be prepended to the existing or created arrayothers
- more optional longs to be prependeddefault T prepend(String path, boolean elem, boolean... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the path-like string pointing to the array in which all the string will be prependedelem
- the first boolean to be prepended to the existing or created arrayothers
- more optional booleans to be prependeddefault T prepend(String path, double elem, double... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the path-like string pointing to the array in which all the string will be prependedelem
- the first double to be prepended to the existing or created arrayothers
- more optional doubles to be prependeddefault T prepend(JsPath path, String elem, String... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the path-like string pointing to the array in which all the string will be prependedelem
- the first string to be prepended to the existing or created arrayothers
- more optional strings to be prependeddefault T prepend(JsPath path, int elem, int... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the JsPath pointing to the array in which all the integers will be prependedelem
- the first integer to be prepended to the existing or created arrayothers
- more optional integers to be prependeddefault T prepend(JsPath path, long elem, long... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the JsPath pointing to the array in which all the longs will be prependedelem
- the first long to be prepended to the existing or created arrayothers
- more optional longs to be prependeddefault T prepend(JsPath path, boolean elem, boolean... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the JsPath pointing to the array in which all the booleans will be prependedelem
- the first boolean to be prepended to the existing or created arrayothers
- more optional booleans to be prependeddefault T prepend(JsPath path, double elem, double... others)
JsNull
when necessary.
The same this instance is returned when it's an array and the head of the path is a key or when
it's an object and the head of the path is an index.path
- the JsPath pointing to the array in which all the doubles will be prependedelem
- the first double to be prepended to the existing or created arrayothers
- more optional doubles to be prependeddefault T putIfAbsent(String path, Supplier<? extends JsElem> supplier)
JsNull
empty positions in arrays when necessary. The supplier is not invoked if the element is present.path
- the path-like stringsupplier
- the supplier which computes the new JsElem if absentdefault T putIfPresent(JsPath path, Function<? super JsElem,? extends JsElem> fn)
path
- the given JsPath objectfn
- the function which computes the new JsElem from the existing onedefault T putIfPresent(String path, Function<? super JsElem,? extends JsElem> fn)
path
- the given path-like stringfn
- the function which computes the new JsElem from the existing one<R> Optional<R> reduce(BinaryOperator<R> op, Function<? super JsPair,R> map, Predicate<? super JsPair> predicate)
R
- the type of the operands of the operatorop
- the operator upon two objects of type Rmap
- the mapping function which produces an object of type R from a JsValuepredicate
- the predicate that determines what JsValue will be mapped and reducedOptional
describing the of of the reductionto apply the reduction in all the Json and not only in the first level
<R> Optional<R> reduce_(BinaryOperator<R> op, Function<? super JsPair,R> map, Predicate<? super JsPair> predicate)
R
- the type of the operands of the operatorop
- the operator upon two objects of type Rmap
- the mapping function which produces an object of type R from a JsValuepredicate
- the predicate that determines what JsValue will be mapped and reducedOptional
describing the result of the reductionto apply the reduction only in the first level
T remove(JsPath path)
path
- the given JsPath objectdefault T remove(String path)
path
- the given path-like stringint size()
default int size_()
default OptionalInt size(JsPath path)
path
- the given JsPath objectdefault OptionalInt size_(JsPath path)
path
- the given JsPath objectdefault OptionalInt size(String path)
path
- the given path-like stringdefault OptionalInt size_(String path)
path
- the given path-like stringStream<JsPair> stream_()
Stream
over all the JsPairs in this jsonStream<JsPair> stream()
Stream
over all the JsPairs in the first level of this jsonT toImmutable()
T toMutable()
default boolean containsPath(String path)
path
- the given path-like stringdefault boolean containsPath(JsPath path)
path
- the JsPathboolean containsElem(JsElem element)
element
- the give element JsElem whose presence in this JsArray is to be testeddefault boolean containsElem_(JsElem element)
element
- the give JsElem whose presence in this JsArray is to be testedboolean isMutable()
boolean isImmutable()
Copyright © 2019. All rights reserved.