incubator-bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r995802 - /incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/MetaBean.java
Date Fri, 10 Sep 2010 14:24:12 GMT
Author: mbenson
Date: Fri Sep 10 14:24:12 2010
New Revision: 995802

URL: http://svn.apache.org/viewvc?rev=995802&view=rev
Log:
simplify by switching to ArrayUtils for MetaBean property addition; when new property is null,
remove rather than put null in the array

Modified:
    incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/MetaBean.java

Modified: incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/MetaBean.java
URL: http://svn.apache.org/viewvc/incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/MetaBean.java?rev=995802&r1=995801&r2=995802&view=diff
==============================================================================
--- incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/MetaBean.java
(original)
+++ incubator/bval/sandbox/lang3-work/bval-core/src/main/java/org/apache/bval/model/MetaBean.java
Fri Sep 10 14:24:12 2010
@@ -157,17 +157,14 @@ public class MetaBean extends FeaturesCa
         if (property != null)
             property.setParentMetaBean(this);
         if (oldProperty == null) { // add
-            if (properties.length == 0) {
-                properties = new MetaProperty[1];
-            } else {
-                MetaProperty[] newproperties = new MetaProperty[properties.length + 1];
-                System.arraycopy(properties, 0, newproperties, 0, properties.length);
-                properties = newproperties;
-            }
-            properties[properties.length - 1] = property;
-        } else { // replace
+            properties = ArrayUtils.add(properties, property);
+        } else {
             int idx = ArrayUtils.indexOf(properties, oldProperty);
-            properties[idx] = property;
+            if (property == null) {// remove
+                properties = ArrayUtils.remove(properties, idx);
+            } else { // replace
+                properties[idx] = property;
+            }
         }
     }
 



Mime
View raw message