Felix Meschberger wrote:
> 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.
Hmm, not really :) As soon as a resource implementation wants to
implement more than one mixin, but in some cases only one mixin is
available for a concrete object, this makes the implementation
difficult. But fortunately we don't have to go into the details here
(see below).
>
> 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.
Yepp, that looks very good to me, +1
Carsten
--
Carsten Ziegeler
[EMAIL PROTECTED]