incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1066665 - /incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/MetaContainer.java
Date Wed, 02 Feb 2011 22:28:50 GMT
Author: mbenson
Date: Wed Feb  2 22:28:50 2011
New Revision: 1066665

URL: http://svn.apache.org/viewvc?rev=1066665&view=rev
Log:
consolidate createMergeBean() and merge() for greater flexibility

Modified:
    incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/MetaContainer.java

Modified: incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/MetaContainer.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/MetaContainer.java?rev=1066665&r1=1066664&r2=1066665&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/MetaContainer.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-jsr303d/src/main/java/org/apache/bval/jsr303/dynamic/MetaContainer.java
Wed Feb  2 22:28:50 2011
@@ -113,13 +113,7 @@ public abstract class MetaContainer<K> {
      * @return MetaBean
      */
     public MetaBean getMergedElement(K id) {
-        MetaBean result = createMergeBean();
-        if (id == null) {
-            merge(result, prototype);
-        } else {
-            merge(result, prototype, elements.get(id));
-        }
-        return result;
+        return elements.containsKey(id) ? merge(prototype, elements.get(id)) : merge(prototype);
     }
 
     /**
@@ -132,25 +126,18 @@ public abstract class MetaContainer<K> {
     }
 
     /**
-     * Create a {@link MetaBean} instance for merging.
-     * 
-     * @return MetaBean
-     */
-    protected MetaBean createMergeBean() {
-        return new MetaBean();
-    }
-
-    /**
-     * Merge MetaBeans. Provides a hook for subclasses to see the sources.
+     * Merge MetaBeans.
      * 
-     * @param target
      * @param sources
      *            in order of increasing specificity
+     * @return merged MetaBean
      */
-    protected void merge(MetaBean target, MetaBean... sources) {
+    protected MetaBean merge(MetaBean... sources) {
+        MetaBean result = new MetaBean();
         for (MetaBean source : sources) {
-            copy(target, source);
+            copy(result, source);
         }
+        return result;
     }
 
     /**



Mime
View raw message