You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by pj...@apache.org on 2002/08/10 04:05:21 UTC
cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections TestBeanMap.java
pjack 2002/08/09 19:05:21
Modified: collections/src/java/org/apache/commons/collections
BeanMap.java
collections/src/test/org/apache/commons/collections
TestBeanMap.java
Log:
Added BeanMap.putAllWriteable(BeanMap) method, and unit test.
PR:11262
Revision Changes Path
1.12 +20 -3 jakarta-commons/collections/src/java/org/apache/commons/collections/BeanMap.java
Index: BeanMap.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/BeanMap.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- BeanMap.java 12 Jun 2002 03:59:15 -0000 1.11
+++ BeanMap.java 10 Aug 2002 02:05:20 -0000 1.12
@@ -254,6 +254,23 @@
}
/**
+ * Puts all of the writeable properties from the given BeanMap into this
+ * BeanMap. Read-only properties will be ignored.
+ *
+ * @param map the BeanMap whose properties to put
+ */
+ public void putAllWriteable(BeanMap map) {
+ Iterator readableKeys = map.readMethods.keySet().iterator();
+ while(readableKeys.hasNext()) {
+ Object key = readableKeys.next();
+ if(getWriteMethod(key) != null) {
+ this.put(key, map.get(key));
+ }
+ }
+ }
+
+
+ /**
* This method reinitializes the bean map to have default values for the
* bean's properties. This is accomplished by constructing a new instance
* of the bean which the map uses as its underlying data source. This
1.7 +13 -3 jakarta-commons/collections/src/test/org/apache/commons/collections/TestBeanMap.java
Index: TestBeanMap.java
===================================================================
RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestBeanMap.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TestBeanMap.java 18 Jun 2002 05:35:58 -0000 1.6
+++ TestBeanMap.java 10 Aug 2002 02:05:20 -0000 1.7
@@ -331,4 +331,14 @@
"TestBeanMap.bulkTestMapKeySet.testSimpleSerialization"
};
}
+
+
+ public void testBeanMapPutAllWriteable() {
+ BeanMap map1 = (BeanMap)makeFullMap();
+ BeanMap map2 = (BeanMap)makeFullMap();
+ map2.put("someIntValue", new Integer(0));
+ map1.putAllWriteable(map2);
+ assertEquals(map1.get("someIntValue"), new Integer(0));
+ }
+
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>