Hi,

Am Freitag, den 30.11.2007, 08:08 +0100 schrieb Bertrand Delacretaz:
> (sorry about replying so late, the thread was sitting in my "must act
> on this" folder for too long ;-)

Same for me - I wanted to reply yesterday, around the time I applied the
change, but then ...

> > ...We can think of a beter name for getRawData() - although I really think
> > that it is a good name....
> 
> Considering the above, we might leave just one
> 
>   Object getData()
> 
> method to access data in the Resource, right?
> 
> And for microsling this would return a Node, and in Sling if using OCM
> that would return an Object.

Now that I have applied the changes with the mixin interfaces, I realize
how elegant the solution actually is: Check, whether the resource
provides certain data and call that that by API. This is much more
convenient than having just one method and guessing on its result and
not being able to get other data, such as an URL, etc.

An extended more flexible solution would be something like this:

    public interface Resource {
        ....
        // get this resource as an object of the type or null if not
possible
        <T> T adaptTo(Class<T> type);
    }

this would allow something like this:

    Node node = resource.adaptTo(Node.class);
    if (node != null) {
        ....
    }

as compared to

    if (resource instanceof NodeProvider) {
        Node node = ((NodeProvider) resource).getNode();
    }

This is derived from the Eclipse Adaptable interface.

Regards
Felix

Reply via email to