commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henning P. Schmiedehausen" <...@intermeta.de>
Subject Re: svn commit: r295107 - in /jakarta/commons/proper/beanutils/trunk/src:
Date Thu, 06 Oct 2005 12:18:26 GMT
niallp@apache.org writes:

>     protected Object createProperty(String name, Class type) {
> 
>+        if (type == Object.class) {
>+            return null;
>+        }
>+

When I saw that checkin, I was wondering whether this is not just
something that plasters over the actual problem. As I can see,
currently passing a "null" value to a LDB results in
DynaClass.add(name) instead of DynaClass.add(name, type) being called
(LDB line 438), which in turn uses new DynaProperty(name), which then
is mapped inside the DynaProperty class to DynaProperty(name, Object.class).

How does this differ from set("foo", new Object()); ?

The use of "Object" here is a bit obfuscated IMHO. Maybe we should use
a "NullType" marker object?

	Best regards
		Henning



>         // Create Lists, arrays or DynaBeans
>         if (type.isArray() || List.class.isAssignableFrom(type)) {
>             return createIndexedProperty(name, type);
>@@ -728,7 +732,7 @@
>     }
> 
>     /**
>-     * Create a new Instance of a 'Primitive' Property
>+     * Create a new Instance of a <code>java.lang.Number</code> Property.
>      */
>     protected Object createNumberProperty(String name, Class type) {
> 
>@@ -737,13 +741,18 @@
>     }
> 
>     /**
>-     * Create a new Instance of a 'Mapped' Property
>+     * Create a new Instance of other Property types
>      */
>     protected Object createOtherProperty(String name, Class type) {
> 
>-        if (type == String.class || type == Boolean.class ||
>-            type == Character.class || Date.class.isAssignableFrom(type)) {
>+        if (type == Object.class    ||
>+            type == String.class    ||
>+            type == Boolean.class   ||
>+            type == Character.class ||
>+            Date.class.isAssignableFrom(type)) {
>+
>             return null;
>+
>         }
> 
>         try {

>Modified: jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/LazyDynaBeanTestCase.java
>URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/LazyDynaBeanTestCase.java?rev=295107&r1=295106&r2=295107&view=diff
>==============================================================================
>--- jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/LazyDynaBeanTestCase.java
(original)
>+++ jakarta/commons/proper/beanutils/trunk/src/test/org/apache/commons/beanutils/LazyDynaBeanTestCase.java
Wed Oct  5 13:35:31 2005
>@@ -116,6 +116,21 @@
>     }
> 
>     /**
>+     * Test Getting/Setting a 'null' Property
>+     */
>+    public void testNullProperty() {
>+
>+        // Check the property & value doesn't exist
>+        assertNull("Check Property doesn't exist", dynaClass.getDynaProperty(testProperty));
>+        assertNull("Check Value is null", bean.get(testProperty));
>+
>+        // Set a new property to null
>+        bean.set(testProperty, null);
>+        assertNull("Check Value is still null", bean.get(testProperty));
>+
>+    }
>+
>+    /**
>      * Test Setting a Simple Property when MutableDynaClass is set to restricted
>      */
>     public void testSimplePropertyRestricted() {



>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org

-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
hps@intermeta.de        +49 9131 50 654 0   http://www.intermeta.de/

RedHat Certified Engineer -- Jakarta Turbine Development  -- hero for hire
   Linux, Java, perl, Solaris -- Consulting, Training, Development

		      4 - 8 - 15 - 16 - 23 - 42

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message