Hi,

On Tue, Jul 1, 2014 at 5:16 PM, Felix Meschberger <fmesc...@adobe.com> wrote:
> Am 01.07.2014 um 09:44 schrieb Bertrand Delacretaz <bdelacre...@apache.org>:
> ...Unfortunately, I don't think this works, because the adaptTo signature is:
>
>   public <AdapterType> AdapterType adaptTo(Class<AdapterType> type);
>
> Hence the return type is the same as provided as the argument, that is if you 
> pass
> RequireAdapter<Foo>, you get a RequireAdapter<Foo> object and not a Foo 
> object...

You're right, I overlooked that.

The someObject.adaptTo(RequireAdapter.for(Foo.class)) variant should
work if for(...) returns Foo.class but uses a ThreadLocal to tell the
AdapterManagerImpl about the options. Not sure if it's worth the
effort or if a new API is better, we could implement a bridge between
the new and old API to avoid having to change all existing adapters.

I see that the use case is under discussion anyway, so let's see what
comes out of that...

-Bertrand

Reply via email to