Re: [picocontainer-dev] JSR330 work progress
Paul Hammant <[email protected]> Tue, 3 Aug 2010 09:05:42 -0500
| Newsgroups | gmane.comp.java.picocontainer.devel |
|---|---|
| Message-ID | <[email protected]> |
--0016364ed7f2158cfa048cebd0fe Content-Type: text/plain; charset=ISO-8859-1 Hi Kent, Because generic may not be a class. It may Type (which in itself has no behaviors). Obviously the if/else logic is unsavory. I hope in time there's a more OO way of doing the same. I'm trying to get this with a) all existing tests passing, b) new @Inject tests passing, then c) the whole JSR330 TCK passing. After that there'd be a round of refactorings to make things more polymorphic :) - Paul On Tue, Aug 3, 2010 at 8:28 AM, Kent R. Spillner <[email protected]> wrote: > Hey, dude- > > Why didn't you parameterize Generic to eliminate the if's and the casts? > > public class JTypeHelper { > ...[SNIP]... > > public static boolean isAssignableFrom( > Generic<? extends Class> generic, > Class<?> aClass) { > return generic.getType().isAssignableFrom(aClass); > } > > public static boolean isAssignableTo( > Generic<? extends Class> generic, > Class<?> aClass) { > return aClass.isAssignableFrom(generic.getType()); > } > > public static <T> boolean isPrimitive( > Generic<? extends Class> generic) { > return generic.getType().isPrimitive(); > } > > } > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > --0016364ed7f2158cfa048cebd0fe Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div>Hi Kent,</div><div><br></div>Because generic may not be a class. =A0It= may Type (which in itself has no behaviors). =A0Obviously the if/else logi= c is unsavory. =A0I hope in time there's a more OO way of doing the sam= e. =A0<div> <br></div><div>I'm trying to get this with a) all existing tests passin= g, b) new @Inject tests passing, then c) the whole JSR330 TCK passing. =A0A= fter that there'd be a round of refactorings to make things more polymo= rphic :)<div> <br></div><div>- Paul<br><br><div class=3D"gmail_quote">On Tue, Aug 3, 2010= at 8:28 AM, Kent R. Spillner <span dir=3D"ltr"><<a href=3D"mailto:kspil= [email protected]">[email protected]</a>></span> wrote:<br><blockquote class= =3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd= ing-left:1ex;"> Hey, dude-<br> <br> Why didn't you parameterize Generic to eliminate the if's and the c= asts?<br> <br> public class JTypeHelper {<br> ...[SNIP]...<br> <br> =A0 =A0public static boolean isAssignableFrom(<br> =A0 =A0 =A0 =A0Generic<? extends Class> generic,<br> =A0 =A0 =A0 =A0Class<?> aClass) {<br> =A0 =A0 =A0 =A0 =A0 =A0return generic.getType().isAssignableFrom(aClass);<= br> =A0 =A0}<br> <br> =A0 =A0public static boolean isAssignableTo(<br> =A0 =A0 =A0 =A0Generic<? extends Class> generic,<br> =A0 =A0 =A0 =A0Class<?> aClass) {<br> =A0 =A0 =A0 =A0 =A0 =A0return aClass.isAssignableFrom(generic.getType());<= br> =A0 =A0}<br> <br> =A0 =A0public static <T> boolean isPrimitive(<br> =A0 =A0 =A0 =A0Generic<? extends Class> generic) {<br> =A0 =A0 =A0 =A0 =A0 =A0return generic.getType().isPrimitive();<br> <div><div></div><div class=3D"h5"> =A0 =A0}<br> <br> }<br> <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></div></div> --0016364ed7f2158cfa048cebd0fe--