Uploaded image for project: 'Commons Sandbox'
  1. Commons Sandbox
  2. SANDBOX-387

[BeanUtils2] Implement possibility to find out if a property readable and/or wirtable

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Component/s: BeanUtils2
    • Labels:
      None

      Description

      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:

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

      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.

        Attachments

          Activity

            People

            • Assignee:
              simone.tripodi Simone Tripodi
              Reporter:
              britter Benedikt Ritter

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment