mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 04:16:14 +00:00
refactoring: Improve monad methods (#2300)
This commit is contained in:
1 parent
375120249a
commit
db4fbb3268
1 file changed
+3
-3
@@ -78,7 +78,7 @@ public class Validator<T> {
|
|||||||
* @param message error message when object is invalid
|
* @param message error message when object is invalid
|
||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public Validator<T> validate(Predicate<T> validation, String message) {
|
public Validator<T> validate(Predicate<? super T> validation, String message) {
|
||||||
if (!validation.test(obj)) {
|
if (!validation.test(obj)) {
|
||||||
exceptions.add(new IllegalStateException(message));
|
exceptions.add(new IllegalStateException(message));
|
||||||
}
|
}
|
||||||
@@ -97,8 +97,8 @@ public class Validator<T> {
|
|||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public <U> Validator<T> validate(
|
public <U> Validator<T> validate(
|
||||||
Function<T, U> projection,
|
Function<? super T, ? extends U> projection,
|
||||||
Predicate<U> validation,
|
Predicate<? super U> validation,
|
||||||
String message
|
String message
|
||||||
) {
|
) {
|
||||||
return validate(projection.andThen(validation::test)::apply, message);
|
return validate(projection.andThen(validation::test)::apply, message);
|
||||||
|
|||||||
Reference in new issue
Block a user