[jira] [Created] (SANDBOX-387) [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (SANDBOX-387) [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable

ASF GitHub Bot (Jira)
[BeanUtils2] Implement possibility to find out if a property readable and/or wirtable
-------------------------------------------------------------------------------------

                 Key: SANDBOX-387
                 URL: https://issues.apache.org/jira/browse/SANDBOX-387
             Project: Commons Sandbox
          Issue Type: Improvement
          Components: BeanUtils2
    Affects Versions: Nightly Builds
            Reporter: Benedikt Ritter


Currently there is no possibility to find out, if a property is readable and/or writable.
For example, one has to pass a value to {{setProperty(name).withValue(argument)}} and hope, that the property is writeable (because a {{NoSucheMethodExcpetion}} will be thrown, if it is not). For this reason it would be nice, if one could do something like:

{code:java}
if (on(myBean).isWritable("writeableProperty") {
    on(myBean).setProperty("writableProperty").withValue("This is a String value!");
}
{code}

Solution:

* Add {{public boolean isWritable(String propertyName)}} and {{public boolean isReadable(String propertyName)}} to {{BeanAccessor}}.
* in {{isWritable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
** if so, return true, if {{propertyDescriptor.getWriteMethod() != null}} and false otherwise.
* in {{isReadable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
** if so, return true, if {{propertyDescriptor.getReadMethod() != null}} and false otherwise.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-387) [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable

ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13200781#comment-13200781 ]

Benedikt Ritter commented on SANDBOX-387:
-----------------------------------------

Please comment on the method names. {{on(myBean).isReadble("someString")}} reads a bit like "is myBean readable" rather then "is the property of name 'someString' readable".
An alternative could be {{isPropertyReadable(String propertyName)}}.
               

> [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable
> -------------------------------------------------------------------------------------
>
>                 Key: SANDBOX-387
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-387
>             Project: Commons Sandbox
>          Issue Type: Improvement
>          Components: BeanUtils2
>    Affects Versions: Nightly Builds
>            Reporter: Benedikt Ritter
>
> Currently there is no possibility to find out, if a property is readable and/or writable.
> For example, one has to pass a value to {{setProperty(name).withValue(argument)}} and hope, that the property is writeable (because a {{NoSucheMethodExcpetion}} will be thrown, if it is not). For this reason it would be nice, if one could do something like:
> {code:java}
> if (on(myBean).isWritable("writeableProperty") {
>     on(myBean).setProperty("writableProperty").withValue("This is a String value!");
> }
> {code}
> Solution:
> * Add {{public boolean isWritable(String propertyName)}} and {{public boolean isReadable(String propertyName)}} to {{BeanAccessor}}.
> * in {{isWritable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getWriteMethod() != null}} and false otherwise.
> * in {{isReadable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getReadMethod() != null}} and false otherwise.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-387) [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13200903#comment-13200903 ]

Simone Tripodi commented on SANDBOX-387:
----------------------------------------

Good thought.

I honestly started to prefer much more compact and less explicit (and verbose) sentences, like {{on( myBean ).set( "propertyName" ).with( valueObject )}}, (that involves actual APIs change) so {{on( myBean ).isReadble( "propertyName" )}} is my preferred on.

Anyway,

{code}
if ( on( myBean ).isWritable( "propertyName" )
{
    on( myBean ).setProperty( "propertyName" ).withValue( "This is a String value!" );
}
{code}

looks less functional and redundant, we could move to a new option, something like (more or less):

{code}
ifIsWritable( "propertyName" ).on( myBean ).set( "This is a String value!" );
{code}
               

> [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable
> -------------------------------------------------------------------------------------
>
>                 Key: SANDBOX-387
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-387
>             Project: Commons Sandbox
>          Issue Type: Improvement
>          Components: BeanUtils2
>    Affects Versions: Nightly Builds
>            Reporter: Benedikt Ritter
>
> Currently there is no possibility to find out, if a property is readable and/or writable.
> For example, one has to pass a value to {{setProperty(name).withValue(argument)}} and hope, that the property is writeable (because a {{NoSucheMethodExcpetion}} will be thrown, if it is not). For this reason it would be nice, if one could do something like:
> {code:java}
> if (on(myBean).isWritable("writeableProperty") {
>     on(myBean).setProperty("writableProperty").withValue("This is a String value!");
> }
> {code}
> Solution:
> * Add {{public boolean isWritable(String propertyName)}} and {{public boolean isReadable(String propertyName)}} to {{BeanAccessor}}.
> * in {{isWritable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getWriteMethod() != null}} and false otherwise.
> * in {{isReadable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getReadMethod() != null}} and false otherwise.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Issue Comment Edited] (SANDBOX-387) [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13200903#comment-13200903 ]

Simone Tripodi edited comment on SANDBOX-387 at 2/5/12 9:20 PM:
----------------------------------------------------------------

Good thought.

I honestly started to prefer much more compact and less explicit (and verbose) sentences, like {{on( myBean ).set( "propertyName" ).with( valueObject )}}, (that involves actual APIs change) so {{on( myBean ).isReadble( "propertyName" )}} is my preferred on.

Anyway,

{code}
if ( on( myBean ).isWritable( "propertyName" )
{
    on( myBean ).set( "propertyName" ).with( "This is a String value!" );
}
{code}

looks less functional and redundant, we could move to a new option, something like (more or less):

{code}
ifIsWritable( "propertyName" ).on( myBean ).set( "This is a String value!" );
{code}
               
      was (Author: simone.tripodi):
    Good thought.

I honestly started to prefer much more compact and less explicit (and verbose) sentences, like {{on( myBean ).set( "propertyName" ).with( valueObject )}}, (that involves actual APIs change) so {{on( myBean ).isReadble( "propertyName" )}} is my preferred on.

Anyway,

{code}
if ( on( myBean ).isWritable( "propertyName" )
{
    on( myBean ).setProperty( "propertyName" ).withValue( "This is a String value!" );
}
{code}

looks less functional and redundant, we could move to a new option, something like (more or less):

{code}
ifIsWritable( "propertyName" ).on( myBean ).set( "This is a String value!" );
{code}
                 

> [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable
> -------------------------------------------------------------------------------------
>
>                 Key: SANDBOX-387
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-387
>             Project: Commons Sandbox
>          Issue Type: Improvement
>          Components: BeanUtils2
>    Affects Versions: Nightly Builds
>            Reporter: Benedikt Ritter
>
> Currently there is no possibility to find out, if a property is readable and/or writable.
> For example, one has to pass a value to {{setProperty(name).withValue(argument)}} and hope, that the property is writeable (because a {{NoSucheMethodExcpetion}} will be thrown, if it is not). For this reason it would be nice, if one could do something like:
> {code:java}
> if (on(myBean).isWritable("writeableProperty") {
>     on(myBean).setProperty("writableProperty").withValue("This is a String value!");
> }
> {code}
> Solution:
> * Add {{public boolean isWritable(String propertyName)}} and {{public boolean isReadable(String propertyName)}} to {{BeanAccessor}}.
> * in {{isWritable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getWriteMethod() != null}} and false otherwise.
> * in {{isReadable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getReadMethod() != null}} and false otherwise.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-387) [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13200945#comment-13200945 ]

Benedikt Ritter commented on SANDBOX-387:
-----------------------------------------

I'm +1 for shorter method names. I think ATM we are a bit inconsistent with that. Take for example:
* {{onClassName(String beanTypeName)}}, but
* {{on(B bean)}} (and not onBean)

Since BeanUtils2 is still in sandbox, a change to the API won't be a problem, will it?

I very much like your proposal {{ifIsWritable()...}}. How about:
{code:java}
ifIs( "propertyName" ).writable().on( myBean ).set( "This is a String value!" );
{code}

Then I'm seeing more stuff like that, like:
{code:java}
ifIs( myBean ).subclassing( Class<?> superClass ).invoke( "superClassMethodName" ).with( ... );
ifIs( myBean ).implementing(Class<?> interfaceType).invoke( "interfaceMethodName" ).with( ... );
{code}
               

> [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable
> -------------------------------------------------------------------------------------
>
>                 Key: SANDBOX-387
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-387
>             Project: Commons Sandbox
>          Issue Type: Improvement
>          Components: BeanUtils2
>    Affects Versions: Nightly Builds
>            Reporter: Benedikt Ritter
>
> Currently there is no possibility to find out, if a property is readable and/or writable.
> For example, one has to pass a value to {{setProperty(name).withValue(argument)}} and hope, that the property is writeable (because a {{NoSucheMethodExcpetion}} will be thrown, if it is not). For this reason it would be nice, if one could do something like:
> {code:java}
> if (on(myBean).isWritable("writeableProperty") {
>     on(myBean).setProperty("writableProperty").withValue("This is a String value!");
> }
> {code}
> Solution:
> * Add {{public boolean isWritable(String propertyName)}} and {{public boolean isReadable(String propertyName)}} to {{BeanAccessor}}.
> * in {{isWritable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getWriteMethod() != null}} and false otherwise.
> * in {{isReadable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getReadMethod() != null}} and false otherwise.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (SANDBOX-387) [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

    [ https://issues.apache.org/jira/browse/SANDBOX-387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13200953#comment-13200953 ]

Simone Tripodi commented on SANDBOX-387:
----------------------------------------

BeanUtils2 has never been released, so no issues on breaking APIs.

-1 on your consideration about inconsistency, if someone calls {{on( String argument )}} expects to call methods on the {{String}} instance.

I like the preconditions language idea, but I would prefer stay focused on completing the TODOs beofore, and come back speaking once completed (it will be easier reusing stuff)
               

> [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable
> -------------------------------------------------------------------------------------
>
>                 Key: SANDBOX-387
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-387
>             Project: Commons Sandbox
>          Issue Type: Improvement
>          Components: BeanUtils2
>    Affects Versions: Nightly Builds
>            Reporter: Benedikt Ritter
>
> Currently there is no possibility to find out, if a property is readable and/or writable.
> For example, one has to pass a value to {{setProperty(name).withValue(argument)}} and hope, that the property is writeable (because a {{NoSucheMethodExcpetion}} will be thrown, if it is not). For this reason it would be nice, if one could do something like:
> {code:java}
> if (on(myBean).isWritable("writeableProperty") {
>     on(myBean).setProperty("writableProperty").withValue("This is a String value!");
> }
> {code}
> Solution:
> * Add {{public boolean isWritable(String propertyName)}} and {{public boolean isReadable(String propertyName)}} to {{BeanAccessor}}.
> * in {{isWritable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getWriteMethod() != null}} and false otherwise.
> * in {{isReadable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getReadMethod() != null}} and false otherwise.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (SANDBOX-387) [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/SANDBOX-387?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benedikt Ritter updated SANDBOX-387:
------------------------------------

    Attachment: SANDBOX-387.txt

Patch for this issue created and attached.
I implemented checking for simple properties and for indexed properties. Because there is no MappedPropertyDescriptor present in the Java API I did not know how to handle mapped properties. I added TODO markers for that to the methods.
               

> [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable
> -------------------------------------------------------------------------------------
>
>                 Key: SANDBOX-387
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-387
>             Project: Commons Sandbox
>          Issue Type: Improvement
>          Components: BeanUtils2
>    Affects Versions: Nightly Builds
>            Reporter: Benedikt Ritter
>         Attachments: SANDBOX-387.txt
>
>
> Currently there is no possibility to find out, if a property is readable and/or writable.
> For example, one has to pass a value to {{setProperty(name).withValue(argument)}} and hope, that the property is writeable (because a {{NoSucheMethodExcpetion}} will be thrown, if it is not). For this reason it would be nice, if one could do something like:
> {code:java}
> if (on(myBean).isWritable("writeableProperty") {
>     on(myBean).setProperty("writableProperty").withValue("This is a String value!");
> }
> {code}
> Solution:
> * Add {{public boolean isWritable(String propertyName)}} and {{public boolean isReadable(String propertyName)}} to {{BeanAccessor}}.
> * in {{isWritable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getWriteMethod() != null}} and false otherwise.
> * in {{isReadable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getReadMethod() != null}} and false otherwise.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (SANDBOX-387) [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable

ASF GitHub Bot (Jira)
In reply to this post by ASF GitHub Bot (Jira)

     [ https://issues.apache.org/jira/browse/SANDBOX-387?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Simone Tripodi resolved SANDBOX-387.
------------------------------------

    Resolution: Fixed
      Assignee: Simone Tripodi

patch applied on [r1243717|http://svn.apache.org/viewvc?rev=1243717&view=rev] thanks for the contribution Benedikt.

Please next time pay attention on new files where license header is located, its proper location is before the {{import}} statements.
               

> [BeanUtils2] Implement possibility to find out if a property readable and/or wirtable
> -------------------------------------------------------------------------------------
>
>                 Key: SANDBOX-387
>                 URL: https://issues.apache.org/jira/browse/SANDBOX-387
>             Project: Commons Sandbox
>          Issue Type: Improvement
>          Components: BeanUtils2
>    Affects Versions: Nightly Builds
>            Reporter: Benedikt Ritter
>            Assignee: Simone Tripodi
>         Attachments: SANDBOX-387.txt
>
>
> Currently there is no possibility to find out, if a property is readable and/or writable.
> For example, one has to pass a value to {{setProperty(name).withValue(argument)}} and hope, that the property is writeable (because a {{NoSucheMethodExcpetion}} will be thrown, if it is not). For this reason it would be nice, if one could do something like:
> {code:java}
> if (on(myBean).isWritable("writeableProperty") {
>     on(myBean).setProperty("writableProperty").withValue("This is a String value!");
> }
> {code}
> Solution:
> * Add {{public boolean isWritable(String propertyName)}} and {{public boolean isReadable(String propertyName)}} to {{BeanAccessor}}.
> * in {{isWritable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getWriteMethod() != null}} and false otherwise.
> * in {{isReadable()}} check if a {{PropertyDescriptor}} can be obtained from PropertyRegistry (if not, throw {{NoSuchMethodException}}).
> ** if so, return true, if {{propertyDescriptor.getReadMethod() != null}} and false otherwise.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira