You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Carsten Ziegeler (JIRA)" <ji...@apache.org> on 2018/08/02 15:43:00 UTC

[jira] [Created] (SLING-7800) Support OSGi converter in adaptTo

Carsten Ziegeler created SLING-7800:
---------------------------------------

             Summary: Support OSGi converter in adaptTo
                 Key: SLING-7800
                 URL: https://issues.apache.org/jira/browse/SLING-7800
             Project: Sling
          Issue Type: Improvement
          Components: API
            Reporter: Carsten Ziegeler
         Attachments: converter-patch.txt

The OSGi Converter (https://osgi.org/specification/osgi.cmpn/7.0.0/util.converter.html) is a utility for converting an object into anything.
In the context of Sling resources it might be very handy to use the converter to convert a resource (or the properties of a resource) into a data model (interface).
Therefore we could think about supporting the Converter directly out of the box in adaptTo as all implementations inherit from the SlingAdaptable class.
In order to get the properties of something, an adaptTo Map.class could be used.
Attached is a simple patch demonstration this.
This could be further improved, like leveraging the Resource#getValueMap method etc.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)