bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r997084 - in /incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303: ./ extensions/
Date Tue, 14 Sep 2010 20:38:29 GMT
Author: mbenson
Date: Tue Sep 14 20:38:29 2010
New Revision: 997084

URL: http://svn.apache.org/viewvc?rev=997084&view=rev
Log:
jsr303 metadata implementation changes to simplify some constructors and implement immutability
as detailed in the spec

Modified:
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/BeanDescriptorImpl.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ClassValidator.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintFinderImpl.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodBeanDescriptorImpl.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodDescriptorImpl.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorImpl.java
    incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorMetaBeanFactory.java

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/BeanDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/BeanDescriptorImpl.java?rev=997084&r1=997083&r2=997084&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/BeanDescriptorImpl.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/BeanDescriptorImpl.java
Tue Sep 14 20:38:29 2010
@@ -18,14 +18,14 @@
  */
 package org.apache.bval.jsr303;
 
-
 import org.apache.bval.model.Features;
 import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.MetaProperty;
-import org.apache.bval.model.Validation;
 
 import javax.validation.metadata.BeanDescriptor;
 import javax.validation.metadata.PropertyDescriptor;
+
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -34,80 +34,79 @@ import java.util.Set;
  */
 public class BeanDescriptorImpl extends ElementDescriptorImpl implements BeanDescriptor {
     /**
-     * The {@link ApacheFactoryContext} (not) used by this {@link BeanDescriptorImpl} 
+     * The {@link ApacheFactoryContext} (not) used by this
+     * {@link BeanDescriptorImpl}
      */
     protected final ApacheFactoryContext factoryContext;
 
     /**
      * Create a new BeanDescriptorImpl instance.
+     * 
      * @param factoryContext
      * @param metaBean
-     * @param validations
      */
-    protected BeanDescriptorImpl(ApacheFactoryContext factoryContext, MetaBean metaBean,
-                                 Validation[] validations) {
-        super(metaBean, metaBean.getBeanClass(), validations);
+    protected BeanDescriptorImpl(ApacheFactoryContext factoryContext, MetaBean metaBean)
{
+        super(metaBean, metaBean.getBeanClass(), metaBean.getValidations());
         this.factoryContext = factoryContext;
     }
 
     /**
      * Returns true if the bean involves validation:
-     * - a constraint is hosted on the bean itself
-     * - a constraint is hosted on one of the bean properties
-     * - or a bean property is marked for cascade (@Valid)
-     *
-     * @return true if the bean nvolves validation
+     * <ul>
+     * <li>a constraint is hosted on the bean itself</li>
+     * <li>a constraint is hosted on one of the bean properties, OR</li>
+     * <li>a bean property is marked for cascade (<code>@Valid</code>)</li>
+     * </ul>
+     * 
+     * @return true if the bean involves validation
      */
     public boolean isBeanConstrained() {
-        if (hasAnyConstraints()) return true;
+        if (hasAnyConstraints())
+            return true;
         for (MetaProperty mprop : metaBean.getProperties()) {
-            if (mprop.getMetaBean() != null ||
-                  mprop.getFeature(Features.Property.REF_CASCADE) != null) return true;
+            if (mprop.getMetaBean() != null || mprop.getFeature(Features.Property.REF_CASCADE)
!= null)
+                return true;
         }
         return false;
     }
 
     private boolean hasAnyConstraints() {
-        if (hasConstraints()) return true;
-        if (metaBean.getValidations().length > 0) return true;
+        if (hasConstraints())
+            return true;
         for (MetaProperty mprop : metaBean.getProperties()) {
-            if (mprop.getValidations().length > 0) return true;
+            if (getConstraintDescriptors(mprop.getValidations()).size() > 0)
+                return true;
         }
         return false;
     }
 
     /**
-     * Return the property level constraints for a given propertyName
-     * or null if either the property does not exist or has no constraint
-     * The returned object (and associated objects including ConstraintDescriptors)
-     * are immutable.
-     *
-     * @param propertyName property evaluated
+     * Return the property level constraints for a given propertyName or null if
+     * either the property does not exist or has no constraint The returned
+     * object (and associated objects including ConstraintDescriptors) are
+     * immutable.
+     * 
+     * @param propertyName
+     *            property evaluated
      */
     public PropertyDescriptor getConstraintsForProperty(String propertyName) {
         if (propertyName == null || propertyName.trim().length() == 0) {
             throw new IllegalArgumentException("propertyName cannot be null or empty");
         }
         MetaProperty prop = metaBean.getProperty(propertyName);
-        if (prop == null) return null;
+        if (prop == null)
+            return null;
         // If no constraints and not cascaded, return null
-        if ( prop.getValidations().length == 0 && prop.getFeature(Features.Property.REF_CASCADE)
== null ) {
+        if (prop.getValidations().length == 0 && prop.getFeature(Features.Property.REF_CASCADE)
== null) {
             return null;
         }
         return getPropertyDescriptor(prop);
     }
 
     private PropertyDescriptor getPropertyDescriptor(MetaProperty prop) {
-        PropertyDescriptorImpl edesc =
-                prop.getFeature(Jsr303Features.Property.PropertyDescriptor);
+        PropertyDescriptorImpl edesc = prop.getFeature(Jsr303Features.Property.PropertyDescriptor);
         if (edesc == null) {
-            edesc = new PropertyDescriptorImpl(
-                      metaBean,
-                      prop.getName(),
-                      prop.getValidations());
-            edesc.setCascaded((prop.getMetaBean() != null ||
-                  prop.getFeature(Features.Property.REF_CASCADE) != null));
-            edesc.setPropertyPath(prop.getName());
+            edesc = new PropertyDescriptorImpl(prop);
             prop.putFeature(Jsr303Features.Property.PropertyDescriptor, edesc);
         }
         return edesc;
@@ -115,17 +114,18 @@ public class BeanDescriptorImpl extends 
 
     /**
      * {@inheritDoc}
+     * 
      * @return the property descriptors having at least a constraint defined
      */
     public Set<PropertyDescriptor> getConstrainedProperties() {
         Set<PropertyDescriptor> validatedProperties = new HashSet<PropertyDescriptor>();
         for (MetaProperty prop : metaBean.getProperties()) {
-            if (prop.getValidations().length > 0 || (prop.getMetaBean() != null ||
-                  prop.getFeature(Features.Property.REF_CASCADE) != null)) {
+            if (prop.getValidations().length > 0
+                || (prop.getMetaBean() != null || prop.getFeature(Features.Property.REF_CASCADE)
!= null)) {
                 validatedProperties.add(getPropertyDescriptor(prop));
             }
         }
-        return validatedProperties;
+        return Collections.unmodifiableSet(validatedProperties);
     }
 
     /**

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ClassValidator.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ClassValidator.java?rev=997084&r1=997083&r2=997084&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ClassValidator.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ClassValidator.java
Tue Sep 14 20:38:29 2010
@@ -678,7 +678,7 @@ public class ClassValidator implements C
      * @return {@link BeanDescriptorImpl} instance
      */
     protected BeanDescriptorImpl createBeanDescriptor(MetaBean metaBean) {
-        return new BeanDescriptorImpl(factoryContext, metaBean, metaBean.getValidations());
+        return new BeanDescriptorImpl(factoryContext, metaBean);
     }
 
     private boolean treatMapsLikeBeans = false;

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintFinderImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintFinderImpl.java?rev=997084&r1=997083&r2=997084&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintFinderImpl.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ConstraintFinderImpl.java
Tue Sep 14 20:38:29 2010
@@ -18,7 +18,6 @@
  */
 package org.apache.bval.jsr303;
 
-
 import javax.validation.metadata.ConstraintDescriptor;
 import javax.validation.metadata.ElementDescriptor;
 import javax.validation.metadata.Scope;
@@ -31,6 +30,7 @@ import org.apache.bval.model.MetaBean;
 
 import java.lang.annotation.ElementType;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -46,6 +46,7 @@ final class ConstraintFinderImpl impleme
 
     /**
      * Create a new ConstraintFinderImpl instance.
+     * 
      * @param metaBean
      * @param constraintDescriptors
      */
@@ -60,21 +61,20 @@ final class ConstraintFinderImpl impleme
      */
     public ElementDescriptor.ConstraintFinder unorderedAndMatchingGroups(Class<?>...
groups) {
         Set<ConstraintValidation<?>> matchingDescriptors =
-              new HashSet<ConstraintValidation<?>>(constraintDescriptors.size());
+            new HashSet<ConstraintValidation<?>>(constraintDescriptors.size());
         Groups groupChain = new GroupsComputer().computeGroups(groups);
         for (Group group : groupChain.getGroups()) {
-            if ( group.isDefault() ) {
+            if (group.isDefault()) {
                 // If group is default, check if it gets redefined
                 List<Group> expandedDefaultGroup = metaBean.getFeature(Jsr303Features.Bean.GROUP_SEQUENCE);
-                for ( Group defaultGroupMember : expandedDefaultGroup ) {
+                for (Group defaultGroupMember : expandedDefaultGroup) {
                     for (ConstraintValidation<?> descriptor : constraintDescriptors)
{
                         if (isInScope(descriptor) && isInGroup(descriptor, defaultGroupMember))
{
                             matchingDescriptors.add(descriptor);
                         }
                     }
                 }
-            }
-            else {
+            } else {
                 for (ConstraintValidation<?> descriptor : constraintDescriptors) {
                     if (isInScope(descriptor) && isInGroup(descriptor, group)) {
                         matchingDescriptors.add(descriptor);
@@ -91,9 +91,9 @@ final class ConstraintFinderImpl impleme
     public ElementDescriptor.ConstraintFinder lookingAt(Scope scope) {
         if (scope.equals(Scope.LOCAL_ELEMENT)) {
             findInScopes.remove(Scope.HIERARCHY);
-            for (Iterator<ConstraintValidation<?>> it = constraintDescriptors.iterator();
it.hasNext(); ) {
+            for (Iterator<ConstraintValidation<?>> it = constraintDescriptors.iterator();
it.hasNext();) {
                 ConstraintValidation<?> cv = it.next();
-                if ( cv.getOwner() != metaBean.getBeanClass() ) {
+                if (cv.getOwner() != metaBean.getBeanClass()) {
                     it.remove();
                 }
             }
@@ -106,7 +106,7 @@ final class ConstraintFinderImpl impleme
      */
     public ElementDescriptor.ConstraintFinder declaredOn(ElementType... elementTypes) {
         Set<ConstraintValidation<?>> matchingDescriptors =
-              new HashSet<ConstraintValidation<?>>(constraintDescriptors.size());
+            new HashSet<ConstraintValidation<?>>(constraintDescriptors.size());
         for (ElementType each : elementTypes) {
             for (ConstraintValidation<?> descriptor : constraintDescriptors) {
                 if (isInScope(descriptor) && isAtElement(descriptor, each)) {
@@ -122,17 +122,20 @@ final class ConstraintFinderImpl impleme
     }
 
     private boolean isInScope(ConstraintValidation<?> descriptor) {
-        if (findInScopes.size() == Scope.values().length) return true; // all scopes
+        if (findInScopes.size() == Scope.values().length)
+            return true; // all scopes
         if (metaBean != null) {
             Class<?> owner = descriptor.getOwner();
             for (Scope scope : findInScopes) {
                 switch (scope) {
-                    case LOCAL_ELEMENT:
-                        if (owner.equals(metaBean.getBeanClass())) return true;
-                        break;
-                    case HIERARCHY:
-                        if (!owner.equals(metaBean.getBeanClass())) return true;
-                        break;
+                case LOCAL_ELEMENT:
+                    if (owner.equals(metaBean.getBeanClass()))
+                        return true;
+                    break;
+                case HIERARCHY:
+                    if (!owner.equals(metaBean.getBeanClass()))
+                        return true;
+                    break;
                 }
             }
         }
@@ -143,8 +146,7 @@ final class ConstraintFinderImpl impleme
         return descriptor.getGroups().contains(group.getGroup());
     }
 
-    private ElementDescriptor.ConstraintFinder thisWith(
-          Set<ConstraintValidation<?>> matchingDescriptors) {
+    private ElementDescriptor.ConstraintFinder thisWith(Set<ConstraintValidation<?>>
matchingDescriptors) {
         constraintDescriptors = matchingDescriptors;
         return this;
     }
@@ -152,10 +154,9 @@ final class ConstraintFinderImpl impleme
     /**
      * {@inheritDoc}
      */
-    @SuppressWarnings("unchecked")
     public Set<ConstraintDescriptor<?>> getConstraintDescriptors() {
-        //noinspection RedundantCast
-        return (Set) constraintDescriptors;
+        return constraintDescriptors.isEmpty() ? Collections.<ConstraintDescriptor<?>>
emptySet() : Collections
+            .<ConstraintDescriptor<?>> unmodifiableSet(constraintDescriptors);
     }
 
     /**

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java?rev=997084&r1=997083&r2=997084&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java
Tue Sep 14 20:38:29 2010
@@ -22,6 +22,7 @@ import javax.validation.metadata.Element
 import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.Validation;
 
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -92,13 +93,23 @@ public abstract class ElementDescriptorI
      */
     @SuppressWarnings("unchecked")
     public ElementDescriptor.ConstraintFinder findConstraints() {
-        return new ConstraintFinderImpl(metaBean, (Set) getConstraintDescriptors());
+        return new ConstraintFinderImpl(metaBean, new HashSet((Set) constraintDescriptors));
     }
 
     /**
      * {@inheritDoc}
      */
     public Set<ConstraintDescriptor<?>> getConstraintDescriptors() {
+        return constraintDescriptors.isEmpty() ? Collections.<ConstraintDescriptor<?>>
emptySet() : Collections
+            .unmodifiableSet(constraintDescriptors);
+    }
+
+    /**
+     * Get the mutable {@link ConstraintDescriptor} {@link Set}.
+     * 
+     * @return Set of {@link ConstraintDescriptor}
+     */
+    protected Set<ConstraintDescriptor<?>> getMutableConstraintDescriptors()
{
         return constraintDescriptors;
     }
 

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java?rev=997084&r1=997083&r2=997084&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/PropertyDescriptorImpl.java
Tue Sep 14 20:38:29 2010
@@ -18,12 +18,10 @@
  */
 package org.apache.bval.jsr303;
 
-
 import javax.validation.metadata.PropertyDescriptor;
 
-import org.apache.bval.model.MetaBean;
-import org.apache.bval.model.Validation;
-
+import org.apache.bval.model.Features;
+import org.apache.bval.model.MetaProperty;
 
 /**
  * Description: {@link PropertyDescriptor} implementation.<br/>
@@ -34,16 +32,18 @@ class PropertyDescriptorImpl extends Ele
 
     /**
      * Create a new PropertyDescriptorImpl instance.
-     * @param metaBean
-     * @param propertyPath
-     * @param validations
+     * 
+     * @param property
      */
-    PropertyDescriptorImpl(MetaBean metaBean, String propertyPath, Validation[] validations)
{
-        super(metaBean, metaBean.getProperty(propertyPath).getTypeClass(), validations);
+    PropertyDescriptorImpl(MetaProperty property) {
+        super(property.getParentMetaBean(), property.getTypeClass(), property.getValidations());
+        setCascaded(property.getMetaBean() != null || property.getFeature(Features.Property.REF_CASCADE)
!= null);
+        setPropertyPath(property.getName());
     }
 
     /**
      * Set whether the referenced property is cascaded.
+     * 
      * @param cascaded
      */
     public void setCascaded(boolean cascaded) {
@@ -59,6 +59,7 @@ class PropertyDescriptorImpl extends Ele
 
     /**
      * Set the referenced property path.
+     * 
      * @param propertyPath
      */
     public void setPropertyPath(String propertyPath) {
@@ -76,7 +77,7 @@ class PropertyDescriptorImpl extends Ele
      * {@inheritDoc}
      */
     public String toString() {
-        return "PropertyDescriptorImpl{" + "returnType=" + elementClass + ", propertyPath='"
+
-              propertyPath + '\'' + '}';
+        return "PropertyDescriptorImpl{" + "returnType=" + elementClass + ", propertyPath='"
+ propertyPath + '\''
+            + '}';
     }
 }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodBeanDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodBeanDescriptorImpl.java?rev=997084&r1=997083&r2=997084&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodBeanDescriptorImpl.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodBeanDescriptorImpl.java
Tue Sep 14 20:38:29 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.bval.jsr303.extensions;
 
-
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.util.HashSet;
@@ -26,29 +25,27 @@ import java.util.Set;
 import org.apache.bval.jsr303.ApacheFactoryContext;
 import org.apache.bval.jsr303.BeanDescriptorImpl;
 import org.apache.bval.model.MetaBean;
-import org.apache.bval.model.Validation;
 
 /**
  * Description: {@link MethodBeanDescriptor} implementation.<br/>
  */
-class MethodBeanDescriptorImpl extends BeanDescriptorImpl
-      implements MethodBeanDescriptor {
+class MethodBeanDescriptorImpl extends BeanDescriptorImpl implements MethodBeanDescriptor
{
     private Map<Method, MethodDescriptor> methodConstraints;
     private Map<Constructor<?>, ConstructorDescriptor> constructorConstraints;
 
     /**
      * Create a new MethodBeanDescriptorImpl instance.
+     * 
      * @param factoryContext
      * @param metaBean
-     * @param validations
      */
-    protected MethodBeanDescriptorImpl(ApacheFactoryContext factoryContext,
-                                       MetaBean metaBean, Validation[] validations) {
-        super(factoryContext, metaBean, validations);
+    protected MethodBeanDescriptorImpl(ApacheFactoryContext factoryContext, MetaBean metaBean)
{
+        super(factoryContext, metaBean);
     }
 
     /**
      * Set the map of method constraints for this bean.
+     * 
      * @param methodConstraints
      */
     public void setMethodConstraints(Map<Method, MethodDescriptor> methodConstraints)
{
@@ -57,10 +54,10 @@ class MethodBeanDescriptorImpl extends B
 
     /**
      * Set the map of constructor constraints for this bean.
+     * 
      * @param constructorConstraints
      */
-    public void setConstructorConstraints(
-          Map<Constructor<?>, ConstructorDescriptor> constructorConstraints)
{
+    public void setConstructorConstraints(Map<Constructor<?>, ConstructorDescriptor>
constructorConstraints) {
         this.constructorConstraints = constructorConstraints;
     }
 
@@ -87,6 +84,7 @@ class MethodBeanDescriptorImpl extends B
 
     /**
      * Add a {@link MethodDescriptor} to this {@link MethodBeanDescriptorImpl}.
+     * 
      * @param method
      * @param desc
      */
@@ -102,7 +100,9 @@ class MethodBeanDescriptorImpl extends B
     }
 
     /**
-     * Add a {@link ConstructorDescriptor} to this {@link MethodBeanDescriptorImpl}.
+     * Add a {@link ConstructorDescriptor} to this
+     * {@link MethodBeanDescriptorImpl}.
+     * 
      * @param cons
      * @param desc
      */
@@ -112,6 +112,7 @@ class MethodBeanDescriptorImpl extends B
 
     /**
      * Get the configured method constraints.
+     * 
      * @return {@link Map} of {@link Method} : {@link MethodDescriptor}
      */
     public Map<Method, MethodDescriptor> getMethodConstraints() {
@@ -120,7 +121,9 @@ class MethodBeanDescriptorImpl extends B
 
     /**
      * Get the configured constructor constraints.
-     * @return {@link Map} of {@link Constructor} : {@link ConstructorDescriptor}
+     * 
+     * @return {@link Map} of {@link Constructor} :
+     *         {@link ConstructorDescriptor}
      */
     public Map<Constructor<?>, ConstructorDescriptor> getConstructorConstraints()
{
         return constructorConstraints;

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodDescriptorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodDescriptorImpl.java?rev=997084&r1=997083&r2=997084&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodDescriptorImpl.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodDescriptorImpl.java
Tue Sep 14 20:38:29 2010
@@ -16,10 +16,11 @@
  */
 package org.apache.bval.jsr303.extensions;
 
-
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
+import org.apache.bval.jsr303.ConstraintValidation;
 import org.apache.bval.jsr303.ElementDescriptorImpl;
 import org.apache.bval.model.MetaBean;
 import org.apache.bval.model.Validation;
@@ -27,13 +28,13 @@ import org.apache.bval.model.Validation;
 /**
  * Description: {@link MethodDescriptor} implementation.<br/>
  */
-public class MethodDescriptorImpl extends ElementDescriptorImpl
-      implements MethodDescriptor, ProcedureDescriptor {
+public class MethodDescriptorImpl extends ElementDescriptorImpl implements MethodDescriptor,
ProcedureDescriptor {
     private final List<ParameterDescriptor> parameterDescriptors = new ArrayList<ParameterDescriptor>();
     private boolean cascaded;
 
     /**
      * Create a new MethodDescriptorImpl instance.
+     * 
      * @param metaBean
      * @param validations
      */
@@ -43,6 +44,7 @@ public class MethodDescriptorImpl extend
 
     /**
      * Create a new MethodDescriptorImpl instance.
+     * 
      * @param elementClass
      * @param validations
      */
@@ -53,8 +55,8 @@ public class MethodDescriptorImpl extend
     /**
      * {@inheritDoc}
      */
-    public List<ParameterDescriptor> getParameterDescriptors() //index aligned
-    {
+    public List<ParameterDescriptor> getParameterDescriptors() {
+        // index aligned
         return parameterDescriptors;
     }
 
@@ -72,4 +74,11 @@ public class MethodDescriptorImpl extend
         this.cascaded = cascaded;
     }
 
+    /**
+     * Add the specified validations to this {@link MethodDescriptorImpl}.
+     * @param validations
+     */
+    void addValidations(Collection<ConstraintValidation<?>> validations) {
+        getMutableConstraintDescriptors().addAll(validations);
+    }
 }

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorImpl.java?rev=997084&r1=997083&r2=997084&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorImpl.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorImpl.java
Tue Sep 14 20:38:29 2010
@@ -68,8 +68,7 @@ class MethodValidatorImpl extends ClassV
      */
     @Override
     protected BeanDescriptorImpl createBeanDescriptor(MetaBean metaBean) {
-        MethodBeanDescriptorImpl descriptor =
-            new MethodBeanDescriptorImpl(factoryContext, metaBean, metaBean.getValidations());
+        MethodBeanDescriptorImpl descriptor = new MethodBeanDescriptorImpl(factoryContext,
metaBean);
         MethodValidatorMetaBeanFactory factory = new MethodValidatorMetaBeanFactory(factoryContext);
         factory.buildMethodDescriptor(descriptor);
         return descriptor;

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorMetaBeanFactory.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorMetaBeanFactory.java?rev=997084&r1=997083&r2=997084&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorMetaBeanFactory.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/extensions/MethodValidatorMetaBeanFactory.java
Tue Sep 14 20:38:29 2010
@@ -114,7 +114,7 @@ public class MethodValidatorMetaBeanFact
             processAnnotation(anno, methodDesc, returnAccess, validations);
           }
         }
-        methodDesc.getConstraintDescriptors().addAll(validations.getValidations());
+        methodDesc.addValidations(validations.getValidations());
 
         // parameter validations
         Annotation[][] paramsAnnos = method.getParameterAnnotations();



Mime
View raw message