Author: epbernard
Date: 2009-04-21 07:29:01 -0400 (Tue, 21 Apr 2009)
New Revision: 16372
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintViolationImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
Log:
BVAL-150 add ConstraintViolation#getRootBeanClass
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java 2009-04-21
11:03:38 UTC (rev 16371)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java 2009-04-21
11:29:01 UTC (rev 16372)
@@ -44,6 +44,11 @@
T getRootBean();
/**
+ * @return The class of the root bean being validated
+ */
+ Class<T> getRootBeanClass();
+
+ /**
* If a bean constraint, the bean instance the constraint is applied on
* If a property constraint, the bean instance hosting the property the
* constraint is applied on
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintViolationImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintViolationImpl.java 2009-04-21
11:03:38 UTC (rev 16371)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ConstraintViolationImpl.java 2009-04-21
11:29:01 UTC (rev 16372)
@@ -25,17 +25,18 @@
* @author Hardy Ferentschik
*/
public class ConstraintViolationImpl<T> implements ConstraintViolation<T> {
- private String interpolatedMessage;
- private T rootBean;
- private Object value;
- private String propertyPath;
- private Object leafBeanInstance;
+ private final String interpolatedMessage;
+ private final T rootBean;
+ private final Object value;
+ private final String propertyPath;
+ private final Object leafBeanInstance;
private final ConstraintDescriptor constraintDescriptor;
- private String rawMessage;
+ private final String rawMessage;
+ private final Class<T> rootBeanClass;
- public ConstraintViolationImpl(String messageTemplate, String interpolatedMessage, T
rootBean,
- Object leafBeanInstance, Object value,
+ public ConstraintViolationImpl(String messageTemplate, String interpolatedMessage,
Class<T> rootBeanClass,
+ T rootBean, Object leafBeanInstance, Object value,
String propertyPath, ConstraintDescriptor constraintDescriptor) {
this.rawMessage = messageTemplate;
this.interpolatedMessage = interpolatedMessage;
@@ -44,6 +45,7 @@
this.propertyPath = propertyPath;
this.leafBeanInstance = leafBeanInstance;
this.constraintDescriptor = constraintDescriptor;
+ this.rootBeanClass = rootBeanClass;
}
/**
@@ -64,6 +66,10 @@
return rootBean;
}
+ public Class<T> getRootBeanClass() {
+ return rootBeanClass;
+ }
+
public Object getLeafBean() {
return leafBeanInstance;
}
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java 2009-04-21
11:03:38 UTC (rev 16371)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/ExecutionContext.java 2009-04-21
11:29:01 UTC (rev 16372)
@@ -283,6 +283,7 @@
return new ConstraintViolationImpl<T>(
messageTemplate,
interpolatedMessage,
+ null, //FIXME get the rootBeanClass
getRootBean(),
peekCurrentBean(),
value,