commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r898263 - /commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/FromAnnotationsRuleSet.java
Date Tue, 12 Jan 2010 09:05:59 GMT
Author: simonetripodi
Date: Tue Jan 12 09:05:59 2010
New Revision: 898263

URL: http://svn.apache.org/viewvc?rev=898263&view=rev
Log:
added generics on set/get providers on FromAnnotationsRuleSet class

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=898263&r1=898262&r2=898263&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
Tue Jan 12 09:05:59 2010
@@ -59,7 +59,9 @@
             pattern = entry.getKey();
             for (AnnotationRuleProvider<Annotation, AnnotatedElement, Rule> provider
: entry.getValue()) {
                 rule = provider.get();
-                rule.setNamespaceURI(this.namespaceURI);
+                if (this.namespaceURI != null) {
+                    rule.setNamespaceURI(this.namespaceURI);
+                }
                 digester.addRule(pattern, rule);
             }
         }
@@ -68,18 +70,21 @@
     /**
      * Register an {@link AnnotationRuleProvider} for a specific pattern.
      *
-     * @param pattern
-     * @param ruleProvider
+     * @param pattern the pattern has to be associated to the rule provider.
+     * @param ruleProvider the provider that builds the digester rule.
      */
-    public void addRuleProvider(String pattern, AnnotationRuleProvider<Annotation, AnnotatedElement,
Rule> ruleProvider) {
+    @SuppressWarnings("unchecked")
+    public void addRuleProvider(String pattern, AnnotationRuleProvider<? extends Annotation,
? extends AnnotatedElement, ? extends Rule> ruleProvider) {
+        List<AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>> rules;
+
         if (this.rules.containsKey(pattern)) {
-            this.rules.get(pattern).add(ruleProvider);
+            rules = this.rules.get(pattern);
         } else {
-            List<AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>>
rules =
-                new ArrayList<AnnotationRuleProvider<Annotation, AnnotatedElement,
Rule>>();
-            rules.add(ruleProvider);
+            rules = new ArrayList<AnnotationRuleProvider<Annotation, AnnotatedElement,
Rule>>();
             this.rules.put(pattern, rules);
         }
+
+        rules.add((AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>) ruleProvider);
     }
 
     /**
@@ -92,7 +97,7 @@
      * @return an {@link AnnotationRuleProvider} for the input pattern if found,
      *         null otherwise.
      */
-    public <T extends AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>>
T getProvider(String pattern, Class<T> providerClass) {
+    public <T extends AnnotationRuleProvider<? extends Annotation, ? extends AnnotatedElement,
? extends Rule>> T getProvider(String pattern, Class<T> providerClass) {
         if (!this.rules.containsKey(pattern)) {
             return null;
         }



Mime
View raw message