You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2010/01/14 16:42:00 UTC

svn commit: r899246 - /commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/FromAnnotationsRuleSet.java

Author: simonetripodi
Date: Thu Jan 14 15:42:00 2010
New Revision: 899246

URL: http://svn.apache.org/viewvc?rev=899246&view=rev
Log:
finalized FromAnnotationsRuleSet class
FromAnnotationsRuleSet class remember the types the RuleSet is able to create mapping rules for

Modified:
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/FromAnnotationsRuleSet.java

Modified: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/FromAnnotationsRuleSet.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/FromAnnotationsRuleSet.java?rev=899246&r1=899245&r2=899246&view=diff
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/FromAnnotationsRuleSet.java (original)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/FromAnnotationsRuleSet.java Thu Jan 14 15:42:00 2010
@@ -19,9 +19,11 @@
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.Map.Entry;
 
 import org.apache.commons.digester.Digester;
@@ -35,7 +37,7 @@
  * @version $Id$
  * @since 2.1
  */
-public class FromAnnotationsRuleSet implements RuleSet {
+public final class FromAnnotationsRuleSet implements RuleSet {
 
     /**
      * The data structure that stores the patterns/{@link AnnotationRuleProvider}
@@ -45,6 +47,11 @@
         new LinkedHashMap<String, List<AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>>>();
 
     /**
+     * Maintains all the classes that this RuleSet produces mapping for.
+     */
+    private final Set<Class<?>> mappedClasses = new HashSet<Class<?>>();
+
+    /**
      * The namespace URI.
      */
     private String namespaceURI;
@@ -122,6 +129,27 @@
     }
 
     /**
+     * Checks if this RuleSet builds Digester mapping rules for the input type.
+     *
+     * @param clazz the input type.
+     * @return true, if this RuleSet builds Digester mapping rules for the input
+     *         type, false otherwise.
+     */
+    protected boolean mapsClass(Class<?> clazz) {
+        return this.mappedClasses.contains(clazz);
+    }
+
+    /**
+     * Remember that this RuleSet is able to build Digester mapping rules for
+     * the input type.
+     *
+     * @param clazz the input type.
+     */
+    protected void addMappedClass(Class<?> clazz) {
+        this.mappedClasses.add(clazz);
+    }
+
+    /**
      * Returns the data structure  the patterns/{@link AnnotationRuleProvider}
      * pairs.
      *
@@ -144,7 +172,11 @@
      */
     @Override
     public String toString() {
-        return this.rules.toString();
+        return "{ mappedClasses="
+            + this.mappedClasses
+            + ", rules="
+            + this.rules.toString()
+            + " }";
     }
 
 }