You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "thomas menzel (JIRA)" <ji...@apache.org> on 2008/07/09 13:17:31 UTC

[jira] Created: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

[beanutils] wont recognize isXXX() properties returning Boolean Object
----------------------------------------------------------------------

                 Key: BEANUTILS-321
                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
             Project: Commons BeanUtils
          Issue Type: New Feature
    Affects Versions: 1.7.0
            Reporter: thomas menzel


I have a bean class "Cache" which is generated from jaxb , which has the isEnable method, i can not use the xpath expression "/cache/enable"to retrive the result, is that means BeanUtils only support setXXX getXXX? not support isXXX for boolean values?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612011#action_12612011 ] 

James Carman commented on BEANUTILS-321:
----------------------------------------

How are you getting classes that have Boolean properties set up with "is" accessor methods (IDEs don't generate them that way)?  This can be dangerous, especially with autoboxing (or autounboxing rather), because if the value us null, you'll get a NPE.  If it truly is a binary sort of situation (either it is or it isn't) then you should use boolean, since Boolean is actually somewhat ternary (true, false, null).

> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611990#action_12611990 ] 

James Carman commented on BEANUTILS-321:
----------------------------------------

This is because the JavaBeans specification doesn't say that Boolean properties can have "is" accessor methods, only boolean properties.  See the JavaBeans specification section 8.3.2.

http://java.sun.com/javase/technologies/desktop/javabeans/docs/spec.html

> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612015#action_12612015 ] 

James Carman commented on BEANUTILS-321:
----------------------------------------

By the way, this is mentioned in the API documentation (albeit in a somewhat roundabout way).  The BeanUtils class uses a PropertyUtilsBean:

http://commons.apache.org/beanutils/commons-beanutils-1.7.0/docs/api/org/apache/commons/beanutils/PropertyUtilsBean.html

"The name of the actual getter or setter method to be used is determined using standard JavaBeans instrospection, so that (unless overridden by a BeanInfo class, a property named "xyz" will have a getter method named getXyz() or (*for boolean properties only*) isXyz(), and a setter method named setXyz()."

> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612097#action_12612097 ] 

James Carman commented on BEANUTILS-321:
----------------------------------------

Thomas,

If you do something like:

{code}
if(myBean.isBooleanClass())
{
  // Do something here...
}
{code}

and the Boolean type booleanClass member variable is null, you'll get a null pointer in JDK5+, because the auto-unboxing feature tries to call booleanClass.booleanValue() to unbox it.  If you try to do this in pre-JD5, it won't compile (because Boolean isn't of type boolean, so you can't use it as your conditional in your if statement)

> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton resolved BEANUTILS-321.
---------------------------------------

    Resolution: Won't Fix

> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "Paul Benedict (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612017#action_12612017 ] 

paul4christ79 edited comment on BEANUTILS-321 at 7/9/08 5:08 AM:
-----------------------------------------------------------------

I don't think a Boolean object should be treated like a boolean type. It's not a true/false statement to have three states. In this situation, the property should throw an exception if the underlying property is null or interpret null as false -- but also provide a different property that does get/set with a Boolean object.

      was (Author: paul4christ79):
    I think a Boolean object should be treated like a boolean type.
  
> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612104#action_12612104 ] 

James Carman commented on BEANUTILS-321:
----------------------------------------

Paul,

My point exactly.  A Boolean isn't binary; it's ternary, so that's probably why they didn't include it in the spec, since it's not an is or is not situation.

> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "thomas menzel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612021#action_12612021 ] 

thomas menzel commented on BEANUTILS-321:
-----------------------------------------

> how to get those classes
case a) JAXB 
case b) a class persisted to Hibernate where the state of null is also valid and needs to be reacted upon accordingly

> NPE
why would i get one of those when just copying the property ?
because of converters?
afer all i expect smth. like this to be performed: {{a.isBooleanClass(  b.isBooleanClass() ) }}

> Java doc
i had read that somewhere along trying to find the problem but it didnt click that this meant "native boolean". 
u see, with autoboxing I dont care anymore or only a little about native or not...



> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "thomas menzel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612021#action_12612021 ] 

elonderin edited comment on BEANUTILS-321 at 7/9/08 5:13 AM:
-----------------------------------------------------------------

> how to get those classes
case a) JAXB 
case b) a class persisted to Hibernate where the state of null is also valid and needs to be reacted upon accordingly

> NPE
why would i get one of those when just copying the property ?
because of converters?
afer all i expect smth. like this to be performed: a.setBooleanClass(  b.isBooleanClass() ) 

> Java doc
i had read that somewhere along trying to find the problem but it didnt click that this meant "native boolean". 
u see, with autoboxing I dont care anymore or only a little about native or not...



      was (Author: elonderin):
    > how to get those classes
case a) JAXB 
case b) a class persisted to Hibernate where the state of null is also valid and needs to be reacted upon accordingly

> NPE
why would i get one of those when just copying the property ?
because of converters?
afer all i expect smth. like this to be performed: a.isBooleanClass(  b.isBooleanClass() ) 

> Java doc
i had read that somewhere along trying to find the problem but it didnt click that this meant "native boolean". 
u see, with autoboxing I dont care anymore or only a little about native or not...


  
> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "James Carman (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612097#action_12612097 ] 

jwcarman edited comment on BEANUTILS-321 at 7/9/08 6:35 AM:
----------------------------------------------------------------

Thomas,

If you do something like:

{code}
if(myBean.isBooleanClass())
{
  // Do something here...
}
{code}

and the Boolean type booleanClass member variable is null, you'll get a null pointer in JDK5+, because the auto-unboxing feature tries to call booleanClass.booleanValue() to unbox it.  If you try to do this in pre-JD5, it won't compile (because Boolean isn't of type boolean, so you can't use it as your conditional in your if statement).

And, for the record, I do understand your point.  I've actually encountered this before.  I don't recall the exact situation, but I'm sure I just renamed my "getter."  Have you tried providing a "get" version of your accessor along with the "is" version?  That should probably solve your problem, I think (if you're ok with the potential NPE when accessing the "is" version in a conditional that is).

      was (Author: jwcarman):
    Thomas,

If you do something like:

{code}
if(myBean.isBooleanClass())
{
  // Do something here...
}
{code}

and the Boolean type booleanClass member variable is null, you'll get a null pointer in JDK5+, because the auto-unboxing feature tries to call booleanClass.booleanValue() to unbox it.  If you try to do this in pre-JD5, it won't compile (because Boolean isn't of type boolean, so you can't use it as your conditional in your if statement)
  
> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "thomas menzel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612254#action_12612254 ] 

elonderin edited comment on BEANUTILS-321 at 7/9/08 1:14 PM:
-----------------------------------------------------------------

for JAXB this is a known bug i just found out:

[Sun Bug : xjc generates invalid java beans|http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6708405]

      was (Author: elonderin):
    for JAXB this is a known bug i just found out http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6708405
  
> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "thomas menzel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612021#action_12612021 ] 

elonderin edited comment on BEANUTILS-321 at 7/9/08 5:12 AM:
-----------------------------------------------------------------

> how to get those classes
case a) JAXB 
case b) a class persisted to Hibernate where the state of null is also valid and needs to be reacted upon accordingly

> NPE
why would i get one of those when just copying the property ?
because of converters?
afer all i expect smth. like this to be performed: a.isBooleanClass(  b.isBooleanClass() ) 

> Java doc
i had read that somewhere along trying to find the problem but it didnt click that this meant "native boolean". 
u see, with autoboxing I dont care anymore or only a little about native or not...



      was (Author: elonderin):
    > how to get those classes
case a) JAXB 
case b) a class persisted to Hibernate where the state of null is also valid and needs to be reacted upon accordingly

> NPE
why would i get one of those when just copying the property ?
because of converters?
afer all i expect smth. like this to be performed: {{a.isBooleanClass(  b.isBooleanClass() ) }}

> Java doc
i had read that somewhere along trying to find the problem but it didnt click that this meant "native boolean". 
u see, with autoboxing I dont care anymore or only a little about native or not...


  
> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "thomas menzel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612025#action_12612025 ] 

thomas menzel commented on BEANUTILS-321:
-----------------------------------------

from a design point of view the isXXX() style of naming a boolean property just is a reflection on the engl. language which is more natural when using isXXX() to get the value.
in that context i dont reflect if the Type returned is actually is boolean or Boolean. 

the Bean spec apparently states smth. diff or doesnt really take the Boolean case into consideration, maybe  i should post it there somewhere as i understand that it might no be a good idea to impl. this issue in a BeanUtils class that adheres to the spec. 

for a developer that needs to just copy properties which follow not strictly the bean convention this is confusing.

i hope u get my point but maybe there are others that want to voice an opinion too...

> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "Paul Benedict (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612017#action_12612017 ] 

Paul Benedict commented on BEANUTILS-321:
-----------------------------------------

I think a Boolean object should be treated like a boolean type.

> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "thomas menzel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612254#action_12612254 ] 

thomas menzel commented on BEANUTILS-321:
-----------------------------------------

for JAXB this is a known bug i just found out http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6708405

> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "thomas menzel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

thomas menzel updated BEANUTILS-321:
------------------------------------

    Description: 
it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.

Hence, the test case below will fail.
I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.

Thx

{code:java}
/**
 * @author tmenzel
 * 
 */
public class BeanUtilsTest extends TestCase {

  private class FooBean {
    Boolean booleanClass;

    boolean booleanPrimitive;

    public Boolean isBooleanClass() {
      return booleanClass;
    }

    public void setBooleanClass(Boolean booleanClass) {
      this.booleanClass = booleanClass;
    }

    public boolean isBooleanPrimitive() {
      return booleanPrimitive;
    }

    public void setBooleanPrimitive(boolean booleanPrimitive) {
      this.booleanPrimitive = booleanPrimitive;
    }

  }

  public void testCopyBooleanProps() throws Exception {

    FooBean a = new FooBean();
    a.setBooleanClass(false);
    a.setBooleanPrimitive(false);

    FooBean b = new FooBean();
    b.setBooleanClass(true);
    b.setBooleanPrimitive(true);

    BeanUtils.copyProperties(a, b);

    assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
    assertEquals(a.isBooleanClass(), b.isBooleanClass());

  }
}
{code}

  was:
it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.

Hence, the test case below will fail

{code:java}
/**
 * @author tmenzel
 * 
 */
public class BeanUtilsTest extends TestCase {

  private class FooBean {
    Boolean booleanClass;

    boolean booleanPrimitive;

    public Boolean isBooleanClass() {
      return booleanClass;
    }

    public void setBooleanClass(Boolean booleanClass) {
      this.booleanClass = booleanClass;
    }

    public boolean isBooleanPrimitive() {
      return booleanPrimitive;
    }

    public void setBooleanPrimitive(boolean booleanPrimitive) {
      this.booleanPrimitive = booleanPrimitive;
    }

  }

  public void testCopyBooleanProps() throws Exception {

    FooBean a = new FooBean();
    a.setBooleanClass(false);
    a.setBooleanPrimitive(false);

    FooBean b = new FooBean();
    b.setBooleanClass(true);
    b.setBooleanPrimitive(true);

    BeanUtils.copyProperties(a, b);

    assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
    assertEquals(a.isBooleanClass(), b.isBooleanClass());

  }
}
{code}


> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "thomas menzel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612459#action_12612459 ] 

thomas menzel commented on BEANUTILS-321:
-----------------------------------------

so, now that i have learned why isXXX() : Boolean is not acceptable and can agree on this, 
i wonder if there is some other XxxUtils class to copy non-bean-style [bB]oolean properties that maybe also include: hasXXX(), or shouldXXX() and others prefixes of this style?

or should i add it as another  feature request and close this?

> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "thomas menzel (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

thomas menzel updated BEANUTILS-321:
------------------------------------

    Description: 
it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.

Hence, the test case below will fail

{code:java}
/**
 * @author tmenzel
 * 
 */
public class BeanUtilsTest extends TestCase {

  private class FooBean {
    Boolean booleanClass;

    boolean booleanPrimitive;

    public Boolean isBooleanClass() {
      return booleanClass;
    }

    public void setBooleanClass(Boolean booleanClass) {
      this.booleanClass = booleanClass;
    }

    public boolean isBooleanPrimitive() {
      return booleanPrimitive;
    }

    public void setBooleanPrimitive(boolean booleanPrimitive) {
      this.booleanPrimitive = booleanPrimitive;
    }

  }

  public void testCopyBooleanProps() throws Exception {

    FooBean a = new FooBean();
    a.setBooleanClass(false);
    a.setBooleanPrimitive(false);

    FooBean b = new FooBean();
    b.setBooleanClass(true);
    b.setBooleanPrimitive(true);

    BeanUtils.copyProperties(a, b);

    assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
    assertEquals(a.isBooleanClass(), b.isBooleanClass());

  }
}
{code}

  was:I have a bean class "Cache" which is generated from jaxb , which has the isEnable method, i can not use the xpath expression "/cache/enable"to retrive the result, is that means BeanUtils only support setXXX getXXX? not support isXXX for boolean values?


> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (BEANUTILS-321) [beanutils] wont recognize isXXX() properties returning Boolean Object

Posted by "thomas menzel (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/BEANUTILS-321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12611997#action_12611997 ] 

thomas menzel commented on BEANUTILS-321:
-----------------------------------------

Even so, I still argue that it would be more intuitive if that would be working or at least be configurable somehow.

At least this should be mentioned in the Api as well.

> [beanutils] wont recognize isXXX() properties returning Boolean Object
> ----------------------------------------------------------------------
>
>                 Key: BEANUTILS-321
>                 URL: https://issues.apache.org/jira/browse/BEANUTILS-321
>             Project: Commons BeanUtils
>          Issue Type: New Feature
>    Affects Versions: 1.7.0
>            Reporter: thomas menzel
>
> it seems that an isXXX() style property returning an java.lang.Boolean Object is NOT recognized as the getter peoperty -- at least it wont copy it.
> Hence, the test case below will fail.
> I suggest to handle these props as well, as for a user of BeanUtils this was/is quite surprising to me -- and probably others.
> Thx
> {code:java}
> /**
>  * @author tmenzel
>  * 
>  */
> public class BeanUtilsTest extends TestCase {
>   private class FooBean {
>     Boolean booleanClass;
>     boolean booleanPrimitive;
>     public Boolean isBooleanClass() {
>       return booleanClass;
>     }
>     public void setBooleanClass(Boolean booleanClass) {
>       this.booleanClass = booleanClass;
>     }
>     public boolean isBooleanPrimitive() {
>       return booleanPrimitive;
>     }
>     public void setBooleanPrimitive(boolean booleanPrimitive) {
>       this.booleanPrimitive = booleanPrimitive;
>     }
>   }
>   public void testCopyBooleanProps() throws Exception {
>     FooBean a = new FooBean();
>     a.setBooleanClass(false);
>     a.setBooleanPrimitive(false);
>     FooBean b = new FooBean();
>     b.setBooleanClass(true);
>     b.setBooleanPrimitive(true);
>     BeanUtils.copyProperties(a, b);
>     assertEquals(a.isBooleanPrimitive(), b.isBooleanPrimitive());
>     assertEquals(a.isBooleanClass(), b.isBooleanClass());
>   }
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.