-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: π lenses methods returns impls, nullpointer compose Closes: #149 * ci: π‘ release v8.3.0 pom, changes and readme
- Loading branch information
1 parent
ca746d3
commit 7fa7f5c
Showing
21 changed files
with
185 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
# JSON-VALUES | ||
## v8.2.2 ( Tue Aug 04 2020 15:37:27 GMT+0200 (Central European Summer Time) ) | ||
## v8.3.0 ( Fri Aug 14 2020 02:37:38 GMT+0200 (Central European Summer Time) ) | ||
|
||
|
||
## Features | ||
- πΈ Lens,Option and Prism are public | ||
([5bd2459d](https://github.com/imrafaelmerino/json-values/commit/5bd2459db0551e7b2da182e45965242e1b69ce3f)) | ||
- πΈ TesProperty class to do property based testing | ||
([6ba34465](https://github.com/imrafaelmerino/json-values/commit/6ba34465163e23e7ecd18525424129757f4bfc1c)) | ||
## Bug Fixes | ||
- π lenses methods returns impls, nullpointer compose | ||
([be84679e](https://github.com/imrafaelmerino/json-values/commit/be84679e796dea2f883363470338265c32d14b7b)) | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,31 @@ | ||
package jsonvalues; | ||
|
||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
Represent a Lens which focus is an array located at a path in a Json | ||
@param <S> the type of the whole part, an array or an object */ | ||
class JsArrayLens<S extends Json<S>> extends Lens<S, JsArray> { | ||
JsArrayLens(final JsPath path) { | ||
super(json -> json.getArray(path), | ||
a -> json -> json.set(path, | ||
a) | ||
super(json -> requireNonNull(json).getArray(path), | ||
a -> json -> requireNonNull(json).set(path, | ||
a | ||
) | ||
); | ||
} | ||
|
||
@Override | ||
public <B> Lens<S, B> compose(final Lens<JsArray, B> other) { | ||
return new Lens<>(this.get.andThen(other.get), | ||
b -> s -> { | ||
JsArray o = this.get.apply(requireNonNull(s)); | ||
JsArray newO = other.set.apply(requireNonNull(b)) | ||
.apply(o == null ? JsArray.empty() : o); | ||
return this.set.apply(newO) | ||
.apply(s); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
package jsonvalues; | ||
|
||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
* Represent a Lens which focus is a boolean located at a path in a Json | ||
* | ||
* @param <S> the type of the whole part, an array or an object | ||
*/ | ||
class JsBoolLens<S extends Json<S>> extends Lens<S, Boolean> { | ||
JsBoolLens(final JsPath path) { | ||
super(json -> json.getBool(path), | ||
n -> json -> json.set(path, JsBool.of(n)) | ||
super(json -> requireNonNull(json).getBool(path), | ||
n -> json -> requireNonNull(json).set(path, JsBool.of(n)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
package jsonvalues; | ||
|
||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
Represent a Lens which focus is a double number located at a path in a Json | ||
@param <S> the type of the whole part, an array or an object */ | ||
class JsDoubleLens<S extends Json<S>> extends Lens<S, Double> { | ||
JsDoubleLens(final JsPath path) { | ||
super(json -> json.getDouble(path), | ||
n -> json -> json.set(path, | ||
JsDouble.of(n)) | ||
super(json -> requireNonNull(json).getDouble(path), | ||
n -> json -> requireNonNull(json).set(path, | ||
JsDouble.of(n) | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package jsonvalues; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
* Represent a Lens which focus is an integer number located at a path in a Json | ||
* | ||
* @param <S> the type of the whole part, an array or an object | ||
*/ | ||
class JsIntLens<S extends Json<S>> extends Lens<S, Integer> { | ||
JsIntLens(final JsPath path) { | ||
super(json -> json.getInt(path), | ||
n -> json -> json.set(path, JsInt.of(n)) | ||
super(json -> requireNonNull(json).getInt(path), | ||
n -> json -> requireNonNull(json).set(path, JsInt.of(n)) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1938,5 +1938,7 @@ private Trampoline<JsObj> unionAll(final JsObj a, | |
} | ||
|
||
|
||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
package jsonvalues; | ||
|
||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
/** | ||
Represent a Lens which focus is a json object located at a path is a Json | ||
@param <S> the type of the whole part, an array or an object */ | ||
public class JsObjLens<S extends Json<S>> extends Lens<S, JsObj> { | ||
class JsObjLens<S extends Json<S>> extends Lens<S, JsObj> { | ||
JsObjLens(final JsPath path) { | ||
super(json -> json.getObj(path), | ||
o -> json -> json.set(path, | ||
super(json -> requireNonNull(json).getObj(path), | ||
o -> json -> requireNonNull(json).set(path, | ||
o) | ||
); | ||
} | ||
|
||
|
||
@Override | ||
public <B> Lens<S, B> compose(final Lens<JsObj, B> other) { | ||
return new Lens<>(this.get.andThen(other.get), | ||
b -> s -> { | ||
JsObj o = this.get.apply(requireNonNull(s)); | ||
JsObj newO = other.set.apply(requireNonNull(b)) | ||
.apply(o == null ? JsObj.empty() : o); | ||
return this.set.apply(newO) | ||
.apply(s); | ||
} | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.