Author: epbernard
Date: 2009-03-16 19:26:39 -0400 (Mon, 16 Mar 2009)
New Revision: 16161
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Configuration.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupSequence.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorFactory.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/bootstrap/ProviderSpecificBootstrap.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java
beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ValidationProvider.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorImplTest.java
Log:
BVAL-140 BeanDescriptor.getConstrainedProperties() returns Set<PropertyDescriptor>,
various typos and enhancements
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/BeanDescriptor.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -52,8 +52,8 @@
PropertyDescriptor getConstraintsForProperty(String propertyName);
/**
- * @return the property names having at least one constraint defined or which are
marked
+ * @return the property descriptors having at least one constraint defined or which are
marked
* as cascaded (@Valid) or an empty set.
*/
- Set<String> getConstrainedProperties();
+ Set<PropertyDescriptor> getConstrainedProperties();
}
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Configuration.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Configuration.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Configuration.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -21,7 +21,7 @@
/**
* Receives configuration information, selects the appropriate
- * Bean Validation provider and build the appropriate
+ * Bean Validation provider and builds the appropriate
* ValidatorFactory.
* <p/>
* Usage:
@@ -69,9 +69,8 @@
/**
* Defines the message interpolator used. Has priority over the configuration
* based message interpolator.
- * If null is passed, the default message interpolator
- * (defined in XML or the specification default)
- * is used.
+ * If null is passed, the default message interpolator is used
+ * (defined in XML or the specification default).
*
* @param interpolator message interpolator implementation.
*
@@ -82,9 +81,8 @@
/**
* Defines the traversable resolver used. Has priority over the configuration
* based traversable resolver.
- * If null is passed, the default traversable resolver
- * (defined in XML or the specification default)
- * is used.
+ * If null is passed, the default traversable resolver is used
+ * (defined in XML or the specification default).
*
* @param resolver traversable resolver implementation.
*
@@ -95,9 +93,8 @@
/**
* Defines the constraint validator factory. Has priority over the configuration
* based constraint factory.
- * If null is passed, the default constraint validator factory
- * (defined in XML or the specification default)
- * is used.
+ * If null is passed, the default constraint validator factory is used
+ * (defined in XML or the specification default).
*
* @param constraintValidatorFactory constraint factory inmplementation.
*
@@ -122,14 +119,14 @@
/**
* Add a provider specific property. This property is equivalent to
- * XML Configuration properties.
+ * XML configuration properties.
* If the underlying provider does not know how to handle the property,
* it must silently ignore it.
* <p/>
* Note: Using this non type-safe method is generally not recommended.
* <p/>
* It is more appropriate to use, if available, the type-safe equivalent provided
- * by a specific provider in its Configuration subclass.
+ * by a specific provider via its Configuration subclass.
* <code>ValidatorFactory factory =
Validation.byProvider(ACMEConfiguration.class)
* .configure()
* .providerSpecificProperty(ACMEState.FAST)
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintViolation.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -24,8 +24,6 @@
* well as the message describing the violation.
*
* @author Emmanuel Bernard
- * @todo the rational behind rootBean and propertyPath is to keep the context
- * available to the user
*/
public interface ConstraintViolation<T> {
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupSequence.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupSequence.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/GroupSequence.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -24,7 +24,9 @@
/**
* Define a group sequence
- * Should be hosted by an
+ * The interface hosting @GroupSequence is representing the group sequence.
+ * When hosted on a class, represents the <code>Default</code> group
+ * for that class.
*
* @author Emmanuel Bernard
* @author Hardy Ferentschik
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/MessageInterpolator.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -28,21 +28,22 @@
*/
public interface MessageInterpolator {
/**
- * Interpolate the message from the constraint parameters and the actual validated
object.
- * The locale is defaulted according to the <code>MessageInterpolator</code>
implementation
- * See the implementation documentation for more detail.
+ * Interpolate the message from the constraint parameters and the actual validated
+ * object.
+ * The locale is defaulted according to the
<code>MessageInterpolator</code>
+ * implementation. See the implementation documentation for more detail.
*
* @param messageTemplate The message to interpolate.
* @param context contextual information related to the interpolation
*
* @return Interpolated error message.
*/
- String interpolate(String messageTemplate,
- Context context);
+ String interpolate(String messageTemplate, Context context);
/**
- * Interpolate the message from the constraint parameters and the actual validated
object.
- * The Locale used is provided as a parameter
+ * Interpolate the message from the constraint parameters and the actual validated
+ * object.
+ * The Locale used is provided as a parameter.
*
* @param messageTemplate The message to interpolate.
* @param context contextual information related to the interpolation
@@ -50,9 +51,7 @@
*
* @return Interpolated error message.
*/
- String interpolate(String messageTemplate,
- Context context,
- Locale locale);
+ String interpolate(String messageTemplate, Context context, Locale locale);
/**
* Informations related to the interpolation context
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validation.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -37,7 +37,7 @@
* to bootstrap the framework:
* <ul>
* <li>
- * The easiest approach is to use the default Bean Validation provider.
+ * The easiest approach is to build the default ValidatorFactory.
* <pre>
* ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
* </pre>
@@ -99,7 +99,7 @@
public class Validation {
/**
- * Build and return a ValidatorFactory instanced based on the
+ * Build and return a ValidatorFactory instance based on the
* default Bean Validation provider and following the
* XML configuration.
* <p/>
@@ -125,8 +125,9 @@
* .configure();
* ValidatorFactory factory = configuration.buildValidatorFactory();
* </pre>
- * The actual provider choice is given by the XML configuration. If the XML
- * configuration does not exsist the first available provider will be returned.
+ * The provider can be specified in the XML configuration. If the XML
+ * configuration does not exsist or if no provider is specified,
+ * the first available provider will be returned.
*
* @return instance building a generic <code>Configuration</code>
* compliant with the bootstrap state provided.
@@ -137,7 +138,7 @@
/**
* Build a <code>Configuration</code> for a particular provider
implementation.
- * Optionally override the provider resolution strategy used to determine the provider.
+ * Optionally overrides the provider resolution strategy used to determine the
provider.
* <p/>
* Used by applications targeting a specific provider programmatically.
* <p/>
@@ -156,7 +157,6 @@
*
* @return instance building a provider specific <code>Configuration</code>
* sub interface implementation.
- *
*/
public static <T extends Configuration<T>>
ProviderSpecificBootstrap<T> byProvider(Class<T> configurationType) {
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -42,7 +42,8 @@
<T> Set<ConstraintViolation<T>> validate(T object, Class<?>...
groups);
/**
- * Validates all constraints on <code>propertyName</code>
property of object
+ * Validates all constraints placed on the property named
<code>propertyName</code>
+ * of <code>object</code>
*
* @param object object to validate
* @param propertyName property to validate (ie field and getter constraints)
@@ -61,8 +62,8 @@
Class<?>... groups);
/**
- * Validates all constraints on <code>propertyName</code> property
- * if the property value is <code>value</code>
+ * Validates all constraints placed on the property named
<code>propertyName</code>
+ * would the property value be <code>value</code>
* <p/>
* <code>ConstraintViolation</code> objects return null for
* {@link ConstraintViolation#getRootBean()} and {@link
ConstraintViolation#getLeafBean()}
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorFactory.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorFactory.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ValidatorFactory.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -26,8 +26,8 @@
*/
public interface ValidatorFactory {
/**
- * @return Returns an initialized <code>Validator</code> instance using the
default factory instances
- * for message interpolator and traversable resolver.
+ * @return Returns an initialized <code>Validator</code> instance using the
default
+ * factory instances for message interpolator and traversable resolver.
* <p>
* Validator instances can be pooled and shared by the implementation.
* </p>
@@ -35,15 +35,17 @@
Validator getValidator();
/**
- * Define the validator context and return a <code>Validator</code>
compliant with this state.
+ * Define the validator context and return a <code>Validator</code>
compliant
+ * with this state.
*
* @return a <code>ValidatorContext</code>.
*/
ValidatorContext usingContext();
/**
- * Returns the <code>MessageInterpolator</code> instance configured at
initialization time for the <code>ValidatorFactory<code>.
- * This is the instance used by #getValidator(Class).
+ * Returns the <code>MessageInterpolator</code> instance configured at
+ * initialization time for the <code>ValidatorFactory<code>.
+ * This is the instance used by #getValidator().
*
* @return MessageInterpolator instance.
*/
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/bootstrap/ProviderSpecificBootstrap.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/bootstrap/ProviderSpecificBootstrap.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/bootstrap/ProviderSpecificBootstrap.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -6,7 +6,7 @@
/**
* Defines the state used to bootstrap Bean Validation and
* creates a provider specific Configuration. The specific Configuration
- * sub interface uniquely identifying a provider.
+ * sub interface uniquely identifies a provider.
* <p/>
* The requested provider is the first provider suitable for T (as defined in
* {@link javax.validation.spi.ValidationProvider#isSuitable(Class)}). The
@@ -24,7 +24,7 @@
*
* @param resolver ValidationProviderResolver implementation used
*
- * @return self
+ * @return <code>this</code> following the chaining method pattern
*/
public ProviderSpecificBootstrap<T> providerResolver(ValidationProviderResolver
resolver);
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ConfigurationState.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -37,7 +37,7 @@
/**
* returns true if Configuration.ignoreXMLConfiguration() has been called
- * In this case, the ValiatorFactory must ignore META-INF/validation.xml
+ * In this case, the ValidatorFactory must ignore META-INF/validation.xml
* @return true if META-INF/validation.xml should be ignored
*/
boolean isIgnoreXmlConfiguration();
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ValidationProvider.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ValidationProvider.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/spi/ValidationProvider.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -31,8 +31,9 @@
*/
public interface ValidationProvider {
/**
- * This sub interface uniquely identify a provider.
- *
+ * Return true if <code>configurationClass</code> is the uniquely
identifying
+ * Configuration subclass for this provider
+ *
* @param configurationClass targeted configuration class.
*
* @return <code>true</code> if <code>configurationClass</code>
is the Bean Validation Provider
@@ -43,7 +44,7 @@
/**
* Returns a Configuration instance implementing the
* <code>configurationClass</code> interface.
- * The Configuration instance uses the current provider (<code>this</code>)
+ * The returned Configuration instance must use the current provider
(<code>this</code>)
* to build the ValidatorFactory instance.
* <p/>
* This method can only be called on providers returning true on
@@ -69,14 +70,14 @@
*
* @param state bootstrap state
*
- * @return Configuration implementation
+ * @return Non specialized Configuration implementation
*/
Configuration<?> createGenericConfiguration(BootstrapState state);
/**
* Build a ValidatorFactory using the current provider implementation. The
- * ValidatorFactory is assembled and follow the configuration passed
- * using ConfigurationState.
+ * ValidatorFactory is assembled and follows the configuration passed
+ * via ConfigurationState.
* <p>
* The returned ValidatorFactory is properly initialized and ready for use.
* </p>
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanDescriptorImpl.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -24,7 +24,7 @@
return metadataBean.getPropertyDescriptor( propertyName );
}
- public Set<String> getConstrainedProperties() {
+ public Set<PropertyDescriptor> getConstrainedProperties() {
return metadataBean.getConstrainedProperties();
}
}
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaData.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -79,8 +79,8 @@
PropertyDescriptor getPropertyDescriptor(String property);
/**
- * @return the property names having at least one constraint defined or which are
marked
+ * @return the property descriptors having at least one constraint defined or which are
marked
* as cascaded (@Valid).
*/
- Set<String> getConstrainedProperties();
+ Set<PropertyDescriptor> getConstrainedProperties();
}
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java
===================================================================
---
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validation/engine/BeanMetaDataImpl.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -29,6 +29,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.HashSet;
import javax.validation.BeanDescriptor;
import javax.validation.GroupSequence;
import javax.validation.PropertyDescriptor;
@@ -362,7 +363,7 @@
return defaultGroupSequence;
}
- public Set<String> getConstrainedProperties() {
- return Collections.unmodifiableSet( propertyDescriptors.keySet() );
+ public Set<PropertyDescriptor> getConstrainedProperties() {
+ return Collections.unmodifiableSet( new
HashSet<PropertyDescriptor>(propertyDescriptors.values() ) );
}
}
\ No newline at end of file
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/groups/GroupTest.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -22,6 +22,7 @@
import javax.validation.ConstraintViolation;
import javax.validation.ValidationException;
import javax.validation.Validator;
+import javax.validation.PropertyDescriptor;
import javax.validation.groups.Default;
import static junit.framework.Assert.assertTrue;
@@ -404,7 +405,7 @@
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
assertTrue( beanDescriptor.isBeanConstrained() );
- Set<String> constraintProperties = beanDescriptor.getConstrainedProperties();
+ Set<PropertyDescriptor> constraintProperties =
beanDescriptor.getConstrainedProperties();
assertTrue( "Each of the properties should have at least one constraint.",
constraintProperties.size() == 5 );
Order order = new Order();
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorImplTest.java
===================================================================
---
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorImplTest.java 2009-03-15
17:22:19 UTC (rev 16160)
+++
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validation/engine/metadata/BeanDescriptorImplTest.java 2009-03-16
23:26:39 UTC (rev 16161)
@@ -95,12 +95,17 @@
public void testGetConstrainedProperties() {
Validator validator = TestUtil.getValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
- Set<String> constraintProperties = beanDescriptor.getConstrainedProperties();
+ Set<PropertyDescriptor> constraintProperties =
beanDescriptor.getConstrainedProperties();
assertEquals( "There should be only one property", 1,
constraintProperties.size() );
- assertTrue( "Wrong property", constraintProperties.contains(
"orderNumber" ) );
+ boolean hasOrderNumber = false;
+ for(PropertyDescriptor pd : constraintProperties) {
+ hasOrderNumber |= pd.getPropertyName().equals( "orderNumber" );
+ }
+ assertTrue( "Wrong property", hasOrderNumber );
+
try {
- constraintProperties.add( "foobar" );
+ constraintProperties.add( null );
fail( "Set should be immutable" );
}
catch ( UnsupportedOperationException e ) {