Return-Path: Delivered-To: apmail-incubator-bval-commits-archive@minotaur.apache.org Received: (qmail 8624 invoked from network); 14 Sep 2010 17:07:53 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 14 Sep 2010 17:07:53 -0000 Received: (qmail 47924 invoked by uid 500); 14 Sep 2010 17:07:53 -0000 Delivered-To: apmail-incubator-bval-commits-archive@incubator.apache.org Received: (qmail 47904 invoked by uid 500); 14 Sep 2010 17:07:52 -0000 Mailing-List: contact bval-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: bval-dev@incubator.apache.org Delivered-To: mailing list bval-commits@incubator.apache.org Received: (qmail 47897 invoked by uid 99); 14 Sep 2010 17:07:52 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Sep 2010 17:07:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Sep 2010 17:07:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8FA6C2388999; Tue, 14 Sep 2010 17:07:10 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r996993 - /incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java Date: Tue, 14 Sep 2010 17:07:10 -0000 To: bval-commits@incubator.apache.org From: mbenson@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100914170710.8FA6C2388999@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mbenson Date: Tue Sep 14 17:07:10 2010 New Revision: 996993 URL: http://svn.apache.org/viewvc?rev=996993&view=rev Log: javadoc/refactoring Modified: incubator/bval/sandbox/lang3-work/bval-jsr303/src/main/java/org/apache/bval/jsr303/ElementDescriptorImpl.java 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=996993&r1=996992&r2=996993&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 17:07:10 2010 @@ -16,7 +16,6 @@ */ package org.apache.bval.jsr303; - import javax.validation.metadata.ConstraintDescriptor; import javax.validation.metadata.ElementDescriptor; @@ -30,26 +29,59 @@ import java.util.Set; * Description: MetaData class
*/ public abstract class ElementDescriptorImpl implements ElementDescriptor { + + /** + * Get a set of {@link ConstraintDescriptor}s from the specified array of + * {@link Validation}s. + * + * @param validations + * @return {@link ConstraintDescriptor} set + */ + protected static Set> getConstraintDescriptors(Validation[] validations) { + final Set> result = new HashSet>(validations.length); + for (Validation validation : validations) { + if (validation instanceof ConstraintValidation) { + result.add((ConstraintValidation) validation); + } + } + return result; + } + + /** the MetaBean of this element */ protected final MetaBean metaBean; + + /** the raw type of this element */ protected final Class elementClass; + private Set> constraintDescriptors; - protected ElementDescriptorImpl(MetaBean metaBean, Class elementClass, - Validation[] validations) { + /** + * Create a new ElementDescriptorImpl instance. + * + * @param metaBean + * @param elementClass + * @param validations + */ + protected ElementDescriptorImpl(MetaBean metaBean, Class elementClass, Validation[] validations) { this.metaBean = metaBean; this.elementClass = elementClass; - createConstraintDescriptors(validations); + setConstraintDescriptors(getConstraintDescriptors(validations)); } + /** + * Create a new ElementDescriptorImpl instance. + * + * @param elementClass + * @param validations + */ protected ElementDescriptorImpl(Class elementClass, Validation[] validations) { - this.metaBean = null; - this.elementClass = elementClass; - createConstraintDescriptors(validations); + this(null, elementClass, validations); } /** * {@inheritDoc} - * @return Statically defined returned type. + * + * @return Statically defined returned type. */ public Class getElementClass() { return elementClass; @@ -60,7 +92,7 @@ public abstract class ElementDescriptorI */ @SuppressWarnings("unchecked") public ElementDescriptor.ConstraintFinder findConstraints() { - return new ConstraintFinderImpl(metaBean, (Set) constraintDescriptors); + return new ConstraintFinderImpl(metaBean, (Set) getConstraintDescriptors()); } /** @@ -71,27 +103,18 @@ public abstract class ElementDescriptorI } /** - * {@inheritDoc} - * return true if at least one constraint declaration is present on the element. + * {@inheritDoc} return true if at least one constraint declaration is + * present on the element. */ public boolean hasConstraints() { - return !constraintDescriptors.isEmpty(); - } - - private void createConstraintDescriptors(Validation[] validations) { - final Set> cds = new HashSet>(validations.length); - for (Validation validation : validations) { - if (validation instanceof ConstraintValidation) { - ConstraintValidation cval = (ConstraintValidation) validation; - cds.add(cval); - } - } - setConstraintDescriptors(cds); + return !getConstraintDescriptors().isEmpty(); } /** * Set the constraintDescriptors for this element. - * @param constraintDescriptors to set + * + * @param constraintDescriptors + * to set */ public void setConstraintDescriptors(Set> constraintDescriptors) { this.constraintDescriptors = constraintDescriptors; @@ -99,6 +122,7 @@ public abstract class ElementDescriptorI /** * Get the model {@link MetaBean} used. + * * @return MetaBean */ public MetaBean getMetaBean() {