I'm a bit confused here. You have the JavaSource where the annotation is located, so can't you call field/method/class.getAnnotation(type), which should then give you an AnnotationImpl that you can query?<br><br>What am I missing?<br>
~Lincoln<br><br><div class="gmail_quote">On Sun, Jan 15, 2012 at 9:28 PM, Richard Kennard <span dir="ltr"><<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Lincoln,<br>
<br>
Okay that may work for me. I tried it and Class seems okay. However Annotations are still tricky. I can do...<br>
<br>
if (Annotation.class.isAssignableFrom(returnType))<br>
{<br>
String resolvedType = StringUtils.substringAfter(literalValue, "@");<br>
resolvedType = ((JavaSource<?>) this.annotationSource.getOrigin()).resolveType(resolvedType);<br>
<br>
...and 'resolvedType' is a fully qualified String. But how can I turn that String into a 'proper' AnnotationImpl Object? I need this so I can call<br>
.getLiteralValue(...attribute...) on it.<br>
<br>
Richard.<br>
<div class="im"><br>
On 14/01/2012 4:41 AM, Lincoln Baxter, III wrote:<br>
> Hey Richard,<br>
><br>
> There is a method in JavaSource called resolveType(); This method will return the fully qualified type of the given Class name; however, there is a big<br>
> issue here at the moment. We cannot resolve wildcards, or classes from the same package that are in the 'package' visibility scope.<br>
><br>
> <a href="https://issues.jboss.org/browse/FORGE-424" target="_blank">https://issues.jboss.org/browse/FORGE-424</a><br>
><br>
> In these two cases, resolveType() will actually return the class name unchanged, which is your signal to take desperate measures, because I don't think<br>
> that we will be fixing this in time for .Final. In the case of Column.class, I would start by assuming that the class is what you expect, and in the case<br>
> of other unknown types, at this point - unfortunately - it's going to be up to you to figure out what that type is, and if reasonable assumptions can be<br>
> made.<br>
><br>
> Sorry about this, I know it's a big gap, but it's going to take a lot of work to fix this as you might be able to see in the issue. But definitely call<br>
> resolveType() as a first step, then you'll have to "worry" about handling potential issues where the type information is not available.<br>
><br>
> We also can't tell if a Class literal is a class, interface, enum, etc...<br>
><br>
> ~Lincoln<br>
><br>
</div><div class="im">> On Thu, Jan 12, 2012 at 11:46 PM, Richard Kennard <<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a> <mailto:<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>>> wrote:<br>
><br>
> Lincoln,<br>
><br>
> As you may recall, the new 'static Metawidget' scaffolding tries to reuse Inspectors between the runtime/static worlds. To do this, it needs to reify the<br>
> annotations from org.jboss.forge.parser.java.Annotations into 'proper' java.lang.annotation.Annotations.<br>
><br>
> This is mostly working, but I am struggling with reifying two things:<br>
><br>
> 1. If the annotation's value is a Class<br>
> 2. If the annotation's value is another annotation<br>
><br>
> The problem is the same in both cases - I am lacking the qualified name of the class/annotation. If they user enters:<br>
><br>
> @MyAnnotation( Column.class )<br>
><br>
> Then I need to know that it's actually a javax.persistence.Column.class. This is a bit beyond me! I have left a couple of TODOs in ForgePropertyStyle and<br>
> in ForgePropertyStyleTest. Could you take a look?<br>
><br>
> Regards,<br>
><br>
> Richard.<br>
> _______________________________________________<br>
> forge-dev mailing list<br>
</div>> <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> <mailto:<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>><br>
<div class="HOEnZb"><div class="h5">> <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
><br>
><br>
><br>
><br>
> --<br>
> Lincoln Baxter, III<br>
> <a href="http://ocpsoft.com" target="_blank">http://ocpsoft.com</a><br>
> <a href="http://scrumshark.com" target="_blank">http://scrumshark.com</a><br>
> "Keep it Simple"<br>
><br>
><br>
> _______________________________________________<br>
> forge-dev mailing list<br>
> <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
<br>
_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.com">http://ocpsoft.com</a><br><a href="http://scrumshark.com">http://scrumshark.com</a><br>"Keep it Simple"<br>