[ 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