diff options
author | Tatu Lund <tatu@vaadin.com> | 2020-08-25 18:37:20 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-25 18:37:20 +0300 |
commit | 0a8ef38b0549d8b975e05aa5967cc8e05283bb27 (patch) | |
tree | 7d4bbc92370b83ab8cae810caa859bc4d69c605b /compatibility-server/src | |
parent | 634e83fe76bc37cd9d0d0c097803baab24e86a56 (diff) | |
download | vaadin-framework-0a8ef38b0549d8b975e05aa5967cc8e05283bb27.tar.gz vaadin-framework-0a8ef38b0549d8b975e05aa5967cc8e05283bb27.zip |
Bump hibernate-validator from 4.3.2.Final to 5.3.5.Final (#12083)
Hibernate Validator 5+ requires
- Validation API 2+
- explicit Expression Language dependency
Diffstat (limited to 'compatibility-server/src')
-rw-r--r-- | compatibility-server/src/main/java/com/vaadin/v7/data/validator/BeanValidator.java | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/BeanValidator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/BeanValidator.java index 48bb16753f..49ba4bd69d 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/BeanValidator.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/BeanValidator.java @@ -23,6 +23,7 @@ import java.util.Set; import javax.validation.ConstraintViolation; import javax.validation.MessageInterpolator.Context; import javax.validation.Validation; +import javax.validation.ValidationException; import javax.validation.ValidatorFactory; import javax.validation.metadata.ConstraintDescriptor; @@ -67,6 +68,7 @@ public class BeanValidator implements Validator { protected static class SimpleContext implements Context, Serializable { private final Object value; + private final ConstraintViolation<?> violation; private final ConstraintDescriptor<?> descriptor; /** @@ -74,13 +76,20 @@ public class BeanValidator implements Validator { * * @param value * value being validated - * @param descriptor - * ConstraintDescriptor corresponding to the constraint being + * @param violation + * ConstraintViolation corresponding to the constraint being * validated */ + public SimpleContext(Object value, ConstraintViolation<?> violation) { + this.value = value; + this.violation = violation; + this.descriptor = violation.getConstraintDescriptor(); + } + public SimpleContext(Object value, ConstraintDescriptor<?> descriptor) { this.value = value; this.descriptor = descriptor; + this.violation = null; } @Override @@ -93,6 +102,21 @@ public class BeanValidator implements Validator { return value; } + @Override + public <T> T unwrap(Class<T> type) { + if (violation != null) { + return violation.unwrap(type); + } else { + try { + return type.newInstance(); + } catch (InstantiationException e) { + throw new ValidationException(); + } catch (IllegalAccessException e) { + throw new ValidationException(); + } + } + } + } /** @@ -128,7 +152,7 @@ public class BeanValidator implements Validator { .getMessageInterpolator() .interpolate(violation.getMessageTemplate(), new SimpleContext(value, - violation.getConstraintDescriptor()), + violation), locale); causes[i] = new InvalidValueException(msg); ++i; |