pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gkbr...@mac.com>
Subject Re: Question about generics in some classes
Date Wed, 23 Jun 2010 00:44:40 GMT
With respect to this:

> GetQuery:
> public <T> T execute() {…}

The bigger question is - does it make sense to make GetQuery a generic? You can't add an overload
as described above because the compiler won't like it - type erasure will give it the same
signature as the one that returns an Object. The only way to avoid this is to require the
caller to specify the type when constructing the query:

GetQuery<Foo> fooQuery = new GetQuery<Foo>();
Foo foo = fooQuery.execute();

The other query classes already have well-defined parameter types, so this question really
only applies to GetQuery. I'm not necessarily opposed to it - just thinking out loud.

cc'ing the dev list - comments welcome.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message