On Thu, 2009-05-28 at 10:45 -0700, Gavin King wrote:
On Thu, May 28, 2009 at 10:37 AM, David Allen
<drallendc(a)gmail.com> wrote:
> On Thu, 2009-05-28 at 10:18 -0700, Gavin King wrote:
>> On Thu, May 28, 2009 at 2:14 AM, David Allen <drallendc(a)gmail.com> wrote:
>>
>> > So where do we get T now that the signature has changed to not include
>> > it?
>>
>> do Observer.getClass().
>
> That would be the class Observer. But how do we know what the type of
> the event is? In other words, it would have been the actual type used
> with Observer<T> instead of the parameter T. However, due to erasure,
> that information will not be available inside the addObserver() method.
observer.getClass().getGenericInterfaces()
iterate to find observer, cast to ParameterizedType, call
getActualTypeArguments().
Oops, of course. I wasn't thinking of the implementing class with
observer.getClass().
Good call. Those type parameters are superfluous. :)