Forge - Parent 1.2.2-SNAPSHOT

org.jboss.forge.bus.util
Class Annotations

java.lang.Object
  extended by org.jboss.forge.bus.util.Annotations

public class Annotations
extends Object

Utility class for common @Annotation operations.

TODO: This should probably go into weld-extensions so other portable extensions can leverage it.

Author:
Constructor Summary
Annotations()
           
 
Method Summary
static
<A extends Annotation>
A
getAnnotation(Annotation a, Class<A> type)
          Inspect annotation a for a specific type of annotation.
static
<A extends Annotation>
A
getAnnotation(Class<?> c, Class<A> type)
          Inspect class c for a specific type of annotation.
static
<A extends Annotation>
A
getAnnotation(Method m, Class<A> type)
          Inspect method m for a specific type of annotation.
static boolean isAnnotationPresent(Class<?> c, Class<? extends Annotation> type)
          Discover if a Class c has been annotated with type.
static boolean isAnnotationPresent(Method m, Class<? extends Annotation> type)
          Discover if a Method m has been annotated with type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Annotations

public Annotations()
Method Detail

isAnnotationPresent

public static boolean isAnnotationPresent(Method m,
                                          Class<? extends Annotation> type)
Discover if a Method m has been annotated with type. This also discovers annotations defined through a @Stereotype.

Parameters:
m - The method to inspect.
type - The targeted annotation class
Returns:
True if annotation is present either on the method itself, or on the declaring class of the method. Returns false if the annotation is not present.

isAnnotationPresent

public static boolean isAnnotationPresent(Class<?> c,
                                          Class<? extends Annotation> type)
Discover if a Class c has been annotated with type. This also discovers annotations defined through a @Stereotype.

Parameters:
c - The class to inspect.
type - The targeted annotation class
Returns:
True if annotation is present either on class, false if the annotation is not present.

getAnnotation

public static <A extends Annotation> A getAnnotation(Method m,
                                                     Class<A> type)
Inspect method m for a specific type of annotation. This also discovers annotations defined through a @ Stereotype.

Parameters:
m - The method to inspect.
type - The targeted annotation class
Returns:
The annotation instance found on this method or enclosing class, or null if no matching annotation was found.

getAnnotation

public static <A extends Annotation> A getAnnotation(Annotation a,
                                                     Class<A> type)
Inspect annotation a for a specific type of annotation. This also discovers annotations defined through a @ Stereotype.

Parameters:
m - The method to inspect.
type - The targeted annotation class
Returns:
The annotation instance found on this method or enclosing class, or null if no matching annotation was found.

getAnnotation

public static <A extends Annotation> A getAnnotation(Class<?> c,
                                                     Class<A> type)
Inspect class c for a specific type of annotation. This also discovers annotations defined through a @ Stereotype.

Parameters:
c - The class to inspect.
type - The targeted annotation class
Returns:
The annotation instance found on this class, or null if no matching annotation was found.

Forge - Parent 1.2.2-SNAPSHOT

Copyright © 2013 JBoss by Red Hat. All Rights Reserved.