[seam-dev] Need for Common Annotation-attribute scanning/parsing utility (or CDI API/SPI)

Dan Allen dan.j.allen at gmail.com
Wed Apr 14 14:11:24 EDT 2010


On Wed, Apr 14, 2010 at 2:07 PM, Pete Muir <pmuir at redhat.com> wrote:

>
> On 14 Apr 2010, at 18:59, Dan Allen wrote:
>
> > /**
> >    * Inspect AnnoatedElement <b>element</b> for a specific <b>type</b> of
> annotation. This
> >    * also discovers annotations defined through a @ {@link Stereotype}
> and the CDI SPI. Having found
> >    * the annotation, it is inspected for a member with name
> <b>memberName</b>.
> >    *
> >    * @param element The element to inspect
> >    * @param annotationType The annotation type to check for
> >    * @param memberName The name of the member to look for
> >    * @param expectedMemberType The expectedType of the member
> >    * @param metaAnnotation Whether the annotation may be used as a
> meta-annotation or not
> >    *
> >    * @return The annotation member's value or null if no matching
> annotation was found
> >    * @throws IllegalArgumentException if element, annotationType,
> memberName or expectedMemberType is null
> >    * @throws IllegalArgumentException if the annotationType does not have
> a member of memberName
> >    * @throws ClassCastException if the value of memberName cannot be cast
> to expectedMemberType
> >    */
> >   public static <V> V getAnnotationMemberValue(AnnotatedElement element,
> final Class<A> annotationType, String memberName, Class<V>
> expectedMemberType, boolean metaAnnotation)
> >
> > WDYT?
> >
> > I'm not sure I understand why we need a separate method to get an
> annotation member value. It requires specifying a string name. Why can't we
> simply return the annotation instance and then allow the value to be read by
> invoking the member method?
>
> Actually, I agree with you here, but Lincoln complained mightily about this
> last night so I relented. Ok, let's strike this method.
>
> > I'll admit I was excited about the more fluent method names that Lincoln
> had in his code. Do we really need to have these long method names? Seems
> like pomp and circumstance to me. I suppose that this is what Java has
> always been about, so why take the garb off the queen? Boo.
>
> I believe the consistency with the Java Reflection API is important (BTW
> Lincoln's API wasn't really fluent, just had shorter names).


True, it was just shorter methods. Okay, without the long
"getAnnotationMemberValue", the method names that are left are reasonable ;)

-Dan

-- 
Dan Allen
Senior Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597

http://mojavelinux.com
http://mojavelinux.com/seaminaction
http://www.google.com/profiles/dan.j.allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/seam-dev/attachments/20100414/5177526e/attachment-0001.html 


More information about the seam-dev mailing list