Hi Am 01.07.2014 um 09:44 schrieb Bertrand Delacretaz <bdelacre...@apache.org>:
> On Tue, Jul 1, 2014 at 9:41 AM, Bertrand Delacretaz > <bdelacre...@apache.org> wrote: >> ...how about this: >> >> Foo f = someObject.adaptTo(RequireAdapter.for(Foo.class)); > > Actually, rereading SLING-3714, this can be made simpler with generics > > Foo f = someObject.adaptTo(RequireAdapter<Foo>.class)); > > where RequireAdapter causes AdapterManagerImpl to wrap the adapters to > throw an exception if adaption returns null. 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. Regards Felix > > -Bertrand