Uploaded image for project: 'Jackrabbit Content Repository'
  1. Jackrabbit Content Repository
  2. JCR-3489

enhance get/set Property value access, expanding the supported types set

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

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.5.2
    • None
    • jackrabbit-jcr-commons
    • None

    Description

      The idea is having a small EDSL that simplifies the access to Property value, so rather than coding the following:

      Property property = ...;
      boolean oldValue = property.getBoolean();
      
      boolean newValue = !oldValue;
      property.setValue(newValue);
      

      it could be simplified specifying wich type the users are interested on:

      PropertyAccessors propertiesAccessor = ...;
      
      boolean oldValue = propertiesAccessor.get(property).to(boolean.class);
      
      boolean newValue = !oldValue;
      propertiesAccessor.set(newValue).to(property);
      

      where PropertiesAccessor is the delegated to handle right types handling. By default it supports default Property value types, but it could be extended.

      It could happen also that users would like to support a larger set of types, maybe performing conversions to/from default Property types, so rather than inserting the custom code in the app when required, they could use the PropertiesAccessor; they first need to register the Accessor implementation to (un)bind the type:

      propertiesAccessor.handle(URI.class).with(new PropertyAccessor<URI>() {
      
                  @Override
                  public void set(URI value, Property target) throws ValueFormatException, RepositoryException {
                      // ...
                  }
      
                  @Override
                  public URI get(Property property) throws ValueFormatException, RepositoryException {
                      // TODO ...
                      return null;
                  }
      
              });
      

      so they can use the accessor via the PropertiesAccessor:

      URI oldValue = propertiesAccessor.get(property).to(URI.class);
      
      URI newValue = URI.create("http://jackrabbit.apache.org/");
      propertiesAccessor.set(newValue).to(property);
      

      Patch coming soon!

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            simone.tripodi Simone Tripodi

            Dates

              Created:
              Updated:

              Slack

                Issue deployment