You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bval.apache.org by mb...@apache.org on 2011/02/02 19:51:07 UTC

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

Author: mbenson
Date: Wed Feb  2 18:51:06 2011
New Revision: 1066577

URL: http://svn.apache.org/viewvc?rev=1066577&view=rev
Log:
javadoc; reorder members; extract MetaBean creation to template method

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=1066577&r1=1066576&r2=1066577&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 18:51:06 2011
@@ -27,11 +27,10 @@ import org.apache.commons.lang3.reflect.
 
 /**
  * Represents a "container."
- *
+ * 
  * @version $Rev$ $Date$
  */
 public abstract class MetaContainer<K> {
-
     private final Class<K> idType;
     private final Type elementType;
     private final MetaBean prototype;
@@ -39,46 +38,47 @@ public abstract class MetaContainer<K> {
 
     /**
      * Create a new MetaContainer instance.
+     * 
      * @param parent
      */
     protected MetaContainer(Class<K> idType, Type type) {
         this.idType = idType;
         this.elementType = getElementType(type);
-        prototype = new MetaBean();
+        prototype = createMetaBean();
         prototype.setBeanClass(TypeUtils.getRawType(elementType, type));
     }
 
     /**
-     * Get the element type of a container of type <code>type</code>.
-     * @param type
-     * @return Type
-     */
-    protected abstract Type getElementType(Type type);
-
-    /**
-     * @return the idType
+     * Get the idType.
+     * 
+     * @return Class<K>
      */
     public Class<K> getIdType() {
         return idType;
     }
 
     /**
-     * @return the elementType
+     * Get the elementType.
+     * 
+     * @return Type
      */
     public Type getElementType() {
-
         return elementType;
     }
 
     /**
-     * @return the prototype
+     * Get the prototype.
+     * 
+     * @return MetaBean
      */
     public MetaBean getPrototype() {
         return prototype;
     }
 
     /**
-     * @return the elements
+     * Get the elements.
+     * 
+     * @return ConcurrentMap<K,MetaBean>
      */
     public ConcurrentMap<K, MetaBean> getElements() {
         return elements;
@@ -86,7 +86,7 @@ public abstract class MetaContainer<K> {
 
     /**
      * Get the raw element bean keyed by <code>id</code>.
-     *
+     * 
      * @param id
      * @return MetaBean
      */
@@ -96,7 +96,7 @@ public abstract class MetaContainer<K> {
         }
         MetaBean result = elements.get(id);
         if (result == null) {
-            result = new MetaBean();
+            result = createMetaBean();
             result.setBeanClass(prototype.getBeanClass());
             MetaBean faster = elements.putIfAbsent(id, result);
             if (faster != null) {
@@ -107,14 +107,13 @@ public abstract class MetaContainer<K> {
     }
 
     /**
-     * Get a MetaBean representing the bean keyed by id, merged with the
-     * prototype.
-     *
+     * Get a MetaBean representing the bean keyed by id, merged with the prototype.
+     * 
      * @param id
      * @return MetaBean
      */
     public MetaBean getMergedElement(K id) {
-        MetaBean result = new MetaBean();
+        MetaBean result = createMetaBean();
         copy(result, prototype);
         if (id != null) {
             copy(result, elements.get(id));
@@ -122,4 +121,21 @@ public abstract class MetaContainer<K> {
         return result;
     }
 
+    /**
+     * Create a {@link MetaBean}.
+     * 
+     * @return MetaBean
+     */
+    protected MetaBean createMetaBean() {
+        return new MetaBean();
+    }
+
+    /**
+     * Get the element type of a container of type <code>type</code>.
+     * 
+     * @param type
+     * @return Type
+     */
+    protected abstract Type getElementType(Type type);
+
 }