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&#39;s what I&#39;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">&lt;<a href=3D"mailto:[email protected]">markhobson@gm=
ail.com</a>&gt;</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 &lt;<a href=3D"mailto:markhobson@gmail.=
com">[email protected]</a>&gt; wrote:<br>
&gt; Hi Paul,<br>
&gt;<br>
&gt; On 3 August 2010 12:10, Paul Hammant &lt;<a href=3D"mailto:paul@hamman=
t.org">[email protected]</a>&gt; wrote:<br>
&gt;&gt; Some questions about JType :<br>
&gt;&gt; Much of it is the same as the (much more juvenile) TypeOf that I w=
as<br>
&gt;&gt; evolving. =A0There are some things that I think I&#39;ll need thou=
gh that your<br>
&gt;&gt; don&#39;t have. I say this because I have a pending commit to repl=
ace &#39;TypeOf&#39;<br>
&gt;&gt; with &#39;Generic&#39;. =A0Of course I could be wrong and you have=
 equivalent features<br>
&gt;&gt; that I can&#39;t see yet.<br>
&gt;&gt; Needed Methods:<br>
&gt;&gt; =A0=A0isAssignableFrom(Class aClass)<br>
&gt;&gt; =A0=A0isAssignableTo(Class aClass)<br>
&gt;<br>
&gt; These are both doable with: TypeUtils.isAssignable(Type supertype, Typ=
e type)<br>
&gt;<br>
&gt;&gt; =A0=A0isPrimative()<br>
&gt;<br>
&gt; This would be a nice addition to TypeUtils as isPrimitive(Type). =A0It=
<br>
&gt; shouldn&#39;t take long to implement.<br>
&gt;<br>
&gt;&gt; Needed Constants<br>
&gt;&gt; =A0INTEGER<br>
&gt;&gt; =A0LONG<br>
&gt;&gt; =A0VOID<br>
&gt;&gt; =A0DOUBLE // etc<br>
&gt;<br>
&gt; You shouldn&#39;t need these as you can just use Integer.class,<br>
&gt; Long.class, etc. =A0The idea with Generic is that it doesn&#39;t super=
sede<br>
&gt; Type, Class, etc., but complements them by providing a type literal.<b=
r>
&gt; Generic&lt;T&gt; is just a parameterized wrapper for Type so that Type=
s can<br>
&gt; benefit from type inference as Class&lt;T&gt;.<br>
&gt;<br>
&gt;&gt; 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>

&gt;&gt; I&#39;m also thinking that your toString() is the same as my getNa=
me()<br>
&gt;<br>
&gt; Yep, it&#39;ll give the same result.<br>
&gt;<br>
&gt;&gt; Also a more general question... why did you not choose JType a the=
 base<br>
&gt;&gt; classname? =A0It feels close to what junior developers would feel =
comfortable<br>
&gt;&gt; with given they understand &quot;Class&quot; and &quot;Type&quot;.=
<br>
&gt;<br>
&gt; I chose Generic from the JLS definition:<br>
&gt;<br>
&gt; &quot;A class is generic if it declares one or more type variables&quo=
t;<br>
&gt; <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>
&gt;<br>
&gt; Since that&#39;s typically when Generic is used, with parameterized ty=
pes.<br>
&gt; =A0As mentioned above, Generic is meant to complement Type and Class,<=
br>
&gt; but JType sounds like it supersedes Type. =A0TypeLiteral is the Guice<=
br>
&gt; name for it, but then goes on to define it as &quot;Represents a gener=
ic<br>
&gt; type T&quot; in the Javadocs. =A0Finally, the name JType was chosen wa=
y after<br>
&gt; the library was in use :)<br>
&gt;<br>
&gt;&gt; Moreover, the get<br>
&gt;&gt; factory-method also converts from regular Class (which in itself i=
s not<br>
&gt;&gt; &#39;generic&#39;).<br>
&gt;<br>
&gt; This is true, but this method is used to ease use of Generic. =A0For<b=
r>
&gt; example, consider the following:<br>
&gt;<br>
&gt; &lt;T&gt; T newInstance(Class&lt;T&gt; type) {<br>
&gt; =A0 =A0return newInstance(Generic.get(type));<br>
&gt; }<br>
&gt; &lt;T&gt; T newInstance(Generic&lt;T&gt; type) {<br>
&gt; =A0 =A0// return new instance of T<br>
&gt; }<br>
&gt;<br>
&gt; It allows the method that takes a Class to delegate to the Generic var=
iant.<br>
&gt;<br>
&gt;&gt; Obviously JType/Generic is more evolved than TypeOf.<br>
&gt;&gt; I can send a patch-file if you want to take a look at this Mark :)=
<br>
&gt;<br>
&gt; Is that a patch for JType or Pico? =A0Hopefully you should have<br>
&gt; everything you need in JType aside from the isPrimitive method which<b=
r>
&gt; I&#39;ll add now.<br>
&gt;<br>
&gt; Cheers,<br>
&gt;<br>
&gt; Mark<br>
&gt;<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--