Re: [picocontainer-dev] JSR330 work progress
Paul Hammant <[email protected]> Wed, 4 Aug 2010 06:37:17 -0500
| Newsgroups | gmane.comp.java.picocontainer.devel |
|---|---|
| Message-ID | <[email protected]> |
--0015175cb2041f9eeb048cfddb5d Content-Type: text/plain; charset=ISO-8859-1 Here's what I've penned mark to get it going :- http://github.com/paul-hammant/picocontainer/blob/master/pico/container/src/java/org/picocontainer/JTypeHelper.java On Tue, Aug 3, 2010 at 4:18 PM, Mark Hobson <[email protected]> wrote: > TypeUtils.isPrimitive added in trunk :) > > Mark > > On 3 August 2010 22:06, Mark Hobson <[email protected]> wrote: > > Hi Paul, > > > > On 3 August 2010 12:10, Paul Hammant <[email protected]> wrote: > >> Some questions about JType : > >> Much of it is the same as the (much more juvenile) TypeOf that I was > >> evolving. There are some things that I think I'll need though that your > >> don't have. I say this because I have a pending commit to replace > 'TypeOf' > >> with 'Generic'. Of course I could be wrong and you have equivalent > features > >> that I can't see yet. > >> Needed Methods: > >> isAssignableFrom(Class aClass) > >> isAssignableTo(Class aClass) > > > > These are both doable with: TypeUtils.isAssignable(Type supertype, Type > type) > > > >> isPrimative() > > > > This would be a nice addition to TypeUtils as isPrimitive(Type). It > > shouldn't take long to implement. > > > >> Needed Constants > >> INTEGER > >> LONG > >> VOID > >> DOUBLE // etc > > > > You shouldn't need these as you can just use Integer.class, > > Long.class, etc. The idea with Generic is that it doesn't supersede > > Type, Class, etc., but complements them by providing a type literal. > > Generic<T> is just a parameterized wrapper for Type so that Types can > > benefit from type inference as Class<T>. > > > >> Refer > http://github.com/paul-hammant/picocontainer/blob/f5d973d065dfd4b8281d4feffbb290e0e90f9722/pico/container/src/java/org/picocontainer/TypeOf.java > >> I'm also thinking that your toString() is the same as my getName() > > > > Yep, it'll give the same result. > > > >> Also a more general question... why did you not choose JType a the base > >> classname? It feels close to what junior developers would feel > comfortable > >> with given they understand "Class" and "Type". > > > > I chose Generic from the JLS definition: > > > > "A class is generic if it declares one or more type variables" > > http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.1.2 > > > > Since that's typically when Generic is used, with parameterized types. > > As mentioned above, Generic is meant to complement Type and Class, > > but JType sounds like it supersedes Type. TypeLiteral is the Guice > > name for it, but then goes on to define it as "Represents a generic > > type T" in the Javadocs. Finally, the name JType was chosen way after > > the library was in use :) > > > >> Moreover, the get > >> factory-method also converts from regular Class (which in itself is not > >> 'generic'). > > > > This is true, but this method is used to ease use of Generic. For > > example, consider the following: > > > > <T> T newInstance(Class<T> type) { > > return newInstance(Generic.get(type)); > > } > > <T> T newInstance(Generic<T> type) { > > // return new instance of T > > } > > > > It allows the method that takes a Class to delegate to the Generic > variant. > > > >> Obviously JType/Generic is more evolved than TypeOf. > >> I can send a patch-file if you want to take a look at this Mark :) > > > > Is that a patch for JType or Pico? Hopefully you should have > > everything you need in JType aside from the isPrimitive method which > > I'll add now. > > > > Cheers, > > > > Mark > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --0015175cb2041f9eeb048cfddb5d Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Here's what I've penned mark to get it going :-=A0<a href=3D"http:/= /github.com/paul-hammant/picocontainer/blob/master/pico/container/src/java/= org/picocontainer/JTypeHelper.java">http://github.com/paul-hammant/picocont= ainer/blob/master/pico/container/src/java/org/picocontainer/JTypeHelper.jav= a</a><br> <br><div class=3D"gmail_quote">On Tue, Aug 3, 2010 at 4:18 PM, Mark Hobson = <span dir=3D"ltr"><<a href=3D"mailto:[email protected]">markhobson@gm= ail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D= "margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> TypeUtils.isPrimitive added in trunk :)<br> <font color=3D"#888888"><br> Mark<br> </font><div><div></div><div class=3D"h5"><br> On 3 August 2010 22:06, Mark Hobson <<a href=3D"mailto:markhobson@gmail.= com">[email protected]</a>> wrote:<br> > Hi Paul,<br> ><br> > On 3 August 2010 12:10, Paul Hammant <<a href=3D"mailto:paul@hamman= t.org">[email protected]</a>> wrote:<br> >> Some questions about JType :<br> >> Much of it is the same as the (much more juvenile) TypeOf that I w= as<br> >> evolving. =A0There are some things that I think I'll need thou= gh that your<br> >> don't have. I say this because I have a pending commit to repl= ace 'TypeOf'<br> >> with 'Generic'. =A0Of course I could be wrong and you have= equivalent features<br> >> that I can't see yet.<br> >> Needed Methods:<br> >> =A0=A0isAssignableFrom(Class aClass)<br> >> =A0=A0isAssignableTo(Class aClass)<br> ><br> > These are both doable with: TypeUtils.isAssignable(Type supertype, Typ= e type)<br> ><br> >> =A0=A0isPrimative()<br> ><br> > This would be a nice addition to TypeUtils as isPrimitive(Type). =A0It= <br> > shouldn't take long to implement.<br> ><br> >> Needed Constants<br> >> =A0INTEGER<br> >> =A0LONG<br> >> =A0VOID<br> >> =A0DOUBLE // etc<br> ><br> > You shouldn't need these as you can just use Integer.class,<br> > Long.class, etc. =A0The idea with Generic is that it doesn't super= sede<br> > Type, Class, etc., but complements them by providing a type literal.<b= r> > Generic<T> is just a parameterized wrapper for Type so that Type= s can<br> > benefit from type inference as Class<T>.<br> ><br> >> Refer=A0<a href=3D"http://github.com/paul-hammant/picocontainer/bl= ob/f5d973d065dfd4b8281d4feffbb290e0e90f9722/pico/container/src/java/org/pic= ocontainer/TypeOf.java" target=3D"_blank">http://github.com/paul-hammant/pi= cocontainer/blob/f5d973d065dfd4b8281d4feffbb290e0e90f9722/pico/container/sr= c/java/org/picocontainer/TypeOf.java</a><br> >> I'm also thinking that your toString() is the same as my getNa= me()<br> ><br> > Yep, it'll give the same result.<br> ><br> >> Also a more general question... why did you not choose JType a the= base<br> >> classname? =A0It feels close to what junior developers would feel = comfortable<br> >> with given they understand "Class" and "Type".= <br> ><br> > I chose Generic from the JLS definition:<br> ><br> > "A class is generic if it declares one or more type variables&quo= t;<br> > <a href=3D"http://java.sun.com/docs/books/jls/third_edition/html/class= es.html#8.1.2" target=3D"_blank">http://java.sun.com/docs/books/jls/third_e= dition/html/classes.html#8.1.2</a><br> ><br> > Since that's typically when Generic is used, with parameterized ty= pes.<br> > =A0As mentioned above, Generic is meant to complement Type and Class,<= br> > but JType sounds like it supersedes Type. =A0TypeLiteral is the Guice<= br> > name for it, but then goes on to define it as "Represents a gener= ic<br> > type T" in the Javadocs. =A0Finally, the name JType was chosen wa= y after<br> > the library was in use :)<br> ><br> >> Moreover, the get<br> >> factory-method also converts from regular Class (which in itself i= s not<br> >> 'generic').<br> ><br> > This is true, but this method is used to ease use of Generic. =A0For<b= r> > example, consider the following:<br> ><br> > <T> T newInstance(Class<T> type) {<br> > =A0 =A0return newInstance(Generic.get(type));<br> > }<br> > <T> T newInstance(Generic<T> type) {<br> > =A0 =A0// return new instance of T<br> > }<br> ><br> > It allows the method that takes a Class to delegate to the Generic var= iant.<br> ><br> >> Obviously JType/Generic is more evolved than TypeOf.<br> >> I can send a patch-file if you want to take a look at this Mark :)= <br> ><br> > Is that a patch for JType or Pico? =A0Hopefully you should have<br> > everything you need in JType aside from the isPrimitive method which<b= r> > I'll add now.<br> ><br> > Cheers,<br> ><br> > Mark<br> ><br> <br> ---------------------------------------------------------------------<br> To unsubscribe from this list, please visit:<br> <br> =A0 =A0<a href=3D"http://xircles.codehaus.org/manage_email" target=3D"_bla= nk">http://xircles.codehaus.org/manage_email</a><br> <br> <br> </div></div></blockquote></div><br> --0015175cb2041f9eeb048cfddb5d--