From d601f8b1582ee69555024a69099bdc4c6f7e7fda Mon Sep 17 00:00:00 2001 From: elmot Date: Wed, 3 Aug 2016 16:04:49 +0300 Subject: Remove exceptions logging from Validator Change-Id: I2ea2ce10e53ccd228ba2c8c5d1e9cd1589c5e692 --- .../main/java/com/vaadin/tokka/data/Validator.java | 51 ++++++++++------------ 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/server/src/main/java/com/vaadin/tokka/data/Validator.java b/server/src/main/java/com/vaadin/tokka/data/Validator.java index 884737de11..e07d1d3de0 100644 --- a/server/src/main/java/com/vaadin/tokka/data/Validator.java +++ b/server/src/main/java/com/vaadin/tokka/data/Validator.java @@ -20,8 +20,6 @@ import java.io.Serializable; import java.util.Objects; import java.util.function.Function; import java.util.function.Predicate; -import java.util.logging.Level; -import java.util.logging.Logger; import com.vaadin.tokka.data.util.Result; @@ -32,7 +30,8 @@ import com.vaadin.tokka.data.util.Result; * failed the validation. *

* For instance, the following validator checks if a number is positive: - * + *

+ * *
  * Validator<Integer> v = num -> {
  *     if (num >= 0)
@@ -41,14 +40,14 @@ import com.vaadin.tokka.data.util.Result;
  *         return Result.error("number must be positive");
  * };
  * 
- * + * * @author Vaadin Ltd. * * @param - * the type of the value to validate - * + * the type of the value to validate + * * @see Result - * + * * @since */ @FunctionalInterface @@ -56,9 +55,9 @@ public interface Validator extends Function>, Serializable { /** * Returns a validator that passes any value. - * + * * @param - * the value type + * the value type * @return an always-passing validator */ public static Validator alwaysPass() { @@ -73,17 +72,17 @@ public interface Validator extends Function>, Serializable { *

* For instance, the following chained validator checks if a number is * between 0 and 10, inclusive: - * + *

*
      * Validator<Integer> v = Validator
      *         .from(num -> num >= 0, "number must be >= 0")
      *         .chain(Validator.from(num -> num <= 10, "number must be <= 10"));
      * 
- * + * * @param next - * the validator to apply next, not null + * the validator to apply next, not null * @return a chained validator - * + * * @see #from(Predicate, String) */ public default Validator chain(Function> next) { @@ -96,9 +95,9 @@ public interface Validator extends Function>, Serializable { * the outcome of the validation: either {@link Result#ok(Object) Result.ok} * if the value passed validation or {@link Result#error(String) * Result.error} otherwise. - * + * * @param value - * the input value to validate + * the input value to validate * @return the validation result */ @Override @@ -112,19 +111,19 @@ public interface Validator extends Function>, Serializable { *

* For instance, the following validator checks if a number is between 0 and * 10, inclusive: - * + *

*
      * Validator<Integer> v = Validator.from(
      *         num -> num >= 0 && num <= 10,
      *         "number must be between 0 and 10");
      * 
- * + * * @param - * the value type + * the value type * @param guard - * the function used to validate, not null + * the function used to validate, not null * @param errorMessage - * the message returned if validation fails, not null + * the message returned if validation fails, not null * @return the new validator using the function */ public static Validator from(Predicate guard, @@ -132,15 +131,9 @@ public interface Validator extends Function>, Serializable { Objects.requireNonNull(guard, "guard cannot be null"); Objects.requireNonNull(errorMessage, "errorMessage cannot be null"); return value -> { - try { - if (guard.test(value)) { - return Result.ok(value); - } else { - return Result.error(errorMessage); - } - } catch (Exception e) { - Logger.getLogger(Validator.class.getName()).log(Level.FINE, - errorMessage, e); + if (guard.test(value)) { + return Result.ok(value); + } else { return Result.error(errorMessage); } }; -- cgit v1.2.3