[forge-dev] Possible to lookup classes in project being forged?

Lincoln Baxter, III lincolnbaxter at gmail.com
Thu Oct 27 23:37:26 EDT 2011


You have to cast the class to the type you want. If you don't know the type
ahead of time, you can call javaSource.getSourceType() then do the cast to
the appropriate JavaClass, JavaAnnotation, JavaEnum, or JavaInterface.

~Lincoln

On Thu, Oct 27, 2011 at 6:19 PM, Richard Kennard <
richard at kennardconsulting.com> wrote:

> Lincoln,
>
> Yeah, I think that's pretty much it, thanks!
>
> How do I get from there to an actual org.jboss.forge.parser.java.JavaClass?
>
> Richard.
>
> On 28/10/2011 9:12 AM, Lincoln Baxter, III wrote:
> > Hey Richard,
> >
> > You can use JavaSourceFacet.getJavaResource("foo.Bar").getJavaSource();
> >
> > Is that what you were looking for?
> >
> > ~Lincoln
> >
> > On Thu, Oct 27, 2011 at 6:26 AM, Richard Kennard <
> richard at kennardconsulting.com <mailto:richard at kennardconsulting.com>>
> wrote:
> >
> >     Hi guys,
> >
> >     I was hoping there was a way in Forge to lookup the classes in the
> project being 'forged'. For example, in regular Java I can do...
> >
> >        Class.forName( "foo.Bar" );
> >
> >     So I was hoping for a Forge equivalent like...
> >
> >        org.jboss.forge.parser.java.JavaClass.forName( "foo.Bar" )
> >
> >     ...that would return me an org.jboss.forge.parser.java.JavaClass
> representing Bar. Note that Bar is a class in the project being forged. It
> is not an
> >     actual Class in the VM.
> >
> >     Regards,
> >
> >     Richard.
> >     _______________________________________________
> >     forge-dev mailing list
> >     forge-dev at lists.jboss.org <mailto:forge-dev at lists.jboss.org>
> >     https://lists.jboss.org/mailman/listinfo/forge-dev
> >
> >
> >
> >
> > --
> > Lincoln Baxter, III
> > http://ocpsoft.com
> > http://scrumshark.com
> > "Keep it Simple"
> >
> >
> > _______________________________________________
> > forge-dev mailing list
> > forge-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/forge-dev
>
> _______________________________________________
> forge-dev mailing list
> forge-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/forge-dev
>



-- 
Lincoln Baxter, III
http://ocpsoft.com
http://scrumshark.com
"Keep it Simple"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/forge-dev/attachments/20111027/de6762b4/attachment.html 


More information about the forge-dev mailing list