org.jboss.webbeans.introspector.jlr
Class AbstractAnnotatedItem<T,S>

java.lang.Object
  extended by org.jboss.webbeans.introspector.jlr.AbstractAnnotatedItem<T,S>
Type Parameters:
T -
S -
All Implemented Interfaces:
AnnotatedItem<T,S>
Direct Known Subclasses:
AbstractAnnotatedMember, AbstractAnnotatedType, AnnotatedParameterImpl

public abstract class AbstractAnnotatedItem<T,S>
extends java.lang.Object
implements AnnotatedItem<T,S>

Represents functionality common for all annotated items, mainly different mappings of the annotations and meta-annotations AbstractAnnotatedItem is an immutable class and therefore threadsafe

Author:
Pete Muir, Nicklas Karlsson
See Also:
AnnotatedItem

Nested Class Summary
static class AbstractAnnotatedItem.AnnotationMap
          Represents a mapping from a annotation type to an annotation implementation
 
Field Summary
 
Fields inherited from interface org.jboss.webbeans.introspector.AnnotatedItem
MAPPED_METAANNOTATIONS
 
Constructor Summary
AbstractAnnotatedItem(AbstractAnnotatedItem.AnnotationMap annotationMap)
          Constructor Also builds the meta-annotation map.
 
Method Summary
protected static AbstractAnnotatedItem.AnnotationMap buildAnnotationMap(java.lang.reflect.AnnotatedElement element)
          Static helper method for building annotation map from an annotated element
protected static AbstractAnnotatedItem.AnnotationMap buildAnnotationMap(java.lang.annotation.Annotation[] annotations)
          Builds the annotation map (annotation type -> annotation)
 boolean equals(java.lang.Object other)
          Compares two AbstractAnnotatedItems
<A extends java.lang.annotation.Annotation>
A
getAnnotation(java.lang.Class<? extends A> annotationType)
          Gets the annotation for a given annotation type.
protected  java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,java.lang.annotation.Annotation> getAnnotationMap()
          Gets the annotation map
 java.util.Set<java.lang.annotation.Annotation> getAnnotations()
          Gets all annotations on this item Populates the annotationSet if it was empty
 java.util.Set<java.lang.annotation.Annotation> getBindingTypes()
          Gets the binding types of the item Looks at the meta-annotations map for annotations with binding type meta-annotation.
 java.lang.annotation.Annotation[] getBindingTypesAsArray()
          Gets (as array) the binding types of the item Looks at the meta-annotations map for annotations with binding type meta-annotation.
protected abstract  S getDelegate()
           
 java.util.Set<java.lang.annotation.Annotation> getMetaAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotationType)
          Gets the set of annotations that contain a given annotation type
 java.lang.annotation.Annotation[] getMetaAnnotationsAsArray(java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotationType)
          Gets (as an array) the set of annotations that contain a given annotation type.
protected static java.lang.Object[] getParameterValues(java.util.List<AnnotatedParameter<java.lang.Object>> parameters, Manager manager)
          Static helper method for getting the current parameter values from a list of annotated parameters.
protected static java.lang.Object[] getParameterValues(java.util.List<AnnotatedParameter<java.lang.Object>> parameters, java.lang.Object specialVal, java.lang.Class<? extends java.lang.annotation.Annotation> specialParam, Manager manager)
          Static helper method for getting the current parameter values from a list of annotated parameters.
 int hashCode()
          Gets the hash code of the actual type
 boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotatedType)
          Checks if an annotation is present on the item
 boolean isAssignableFrom(AnnotatedItem<?,?> that)
          Checks if this item is assignable from another annotated item (through type and actual type arguments)
 boolean isAssignableFrom(java.util.Set<java.lang.Class<?>> types)
          Checks if this item is assignable from any one a set of types
 boolean isProxyable()
          Indicates if the type is proxyable to a set of pre-defined rules
 java.lang.String toDetailedString()
           
 java.lang.String toString()
          Gets a string representation of the item
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.webbeans.introspector.AnnotatedItem
getActualTypeArguments, getName, getType, isFinal, isStatic
 

Constructor Detail

AbstractAnnotatedItem

public AbstractAnnotatedItem(AbstractAnnotatedItem.AnnotationMap annotationMap)
Constructor Also builds the meta-annotation map. Throws a NullPointerException if trying to register a null map

Parameters:
annotationMap - A map of annotation to register
Method Detail

buildAnnotationMap

protected static AbstractAnnotatedItem.AnnotationMap buildAnnotationMap(java.lang.reflect.AnnotatedElement element)
Static helper method for building annotation map from an annotated element

Parameters:
element - The element to examine
Returns:
The annotation map

buildAnnotationMap

protected static AbstractAnnotatedItem.AnnotationMap buildAnnotationMap(java.lang.annotation.Annotation[] annotations)
Builds the annotation map (annotation type -> annotation)

Parameters:
annotations - The array of annotations to map
Returns:
The annotation map

getParameterValues

protected static java.lang.Object[] getParameterValues(java.util.List<AnnotatedParameter<java.lang.Object>> parameters,
                                                       Manager manager)
Static helper method for getting the current parameter values from a list of annotated parameters.

Parameters:
parameters - The list of annotated parameter to look up
manager - The Web Beans manager
Returns:
The object array of looked up values

getParameterValues

protected static java.lang.Object[] getParameterValues(java.util.List<AnnotatedParameter<java.lang.Object>> parameters,
                                                       java.lang.Object specialVal,
                                                       java.lang.Class<? extends java.lang.annotation.Annotation> specialParam,
                                                       Manager manager)
Static helper method for getting the current parameter values from a list of annotated parameters.

Parameters:
parameters - The list of annotated parameter to look up
manager - The Web Beans manager
Returns:
The object array of looked up values

getAnnotation

public <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.Class<? extends A> annotationType)
Gets the annotation for a given annotation type.

Specified by:
getAnnotation in interface AnnotatedItem<T,S>
Parameters:
annotationType - the annotation type to match
Returns:
The annotation if found, null if no match was found
See Also:
AnnotatedItem.getAnnotation(Class)

getMetaAnnotations

public java.util.Set<java.lang.annotation.Annotation> getMetaAnnotations(java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotationType)
Gets the set of annotations that contain a given annotation type

Specified by:
getMetaAnnotations in interface AnnotatedItem<T,S>
Parameters:
metaAnnotationType - The meta-annotation type to match
Returns:
The set of annotations containing this meta-annotation. An empty set is returned if no match is found.
See Also:
AnnotatedItem.getMetaAnnotations(Class)

getMetaAnnotationsAsArray

public java.lang.annotation.Annotation[] getMetaAnnotationsAsArray(java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotationType)
Gets (as an array) the set of annotations that contain a given annotation type. Populates the annotationArray if it was null

Specified by:
getMetaAnnotationsAsArray in interface AnnotatedItem<T,S>
Parameters:
metaAnnotationType - meta-annotation type to match
Returns:
The array of annotations to match. An empty array is returned if no match is found.
See Also:
AnnotatedItem.getMetaAnnotationsAsArray(Class)

getAnnotations

public java.util.Set<java.lang.annotation.Annotation> getAnnotations()
Gets all annotations on this item Populates the annotationSet if it was empty

Specified by:
getAnnotations in interface AnnotatedItem<T,S>
Returns:
The set of annotations on this item.
See Also:
AnnotatedItem.getAnnotations()

isAnnotationPresent

public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotatedType)
Checks if an annotation is present on the item

Specified by:
isAnnotationPresent in interface AnnotatedItem<T,S>
Parameters:
annotatedType - The annotation type to check for
Returns:
True if present, false otherwise.
See Also:
AnnotatedItem.isAnnotationPresent(Class)

getAnnotationMap

protected java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,java.lang.annotation.Annotation> getAnnotationMap()
Gets the annotation map

Returns:
The annotation map

equals

public boolean equals(java.lang.Object other)
Compares two AbstractAnnotatedItems

Overrides:
equals in class java.lang.Object
Parameters:
other - The other item
Returns:
True if equals, false otherwise

isAssignableFrom

public boolean isAssignableFrom(AnnotatedItem<?,?> that)
Checks if this item is assignable from another annotated item (through type and actual type arguments)

Specified by:
isAssignableFrom in interface AnnotatedItem<T,S>
Parameters:
that - The other annotated item to check against
Returns:
True if assignable, false otherwise
See Also:
AnnotatedItem.isAssignableFrom(AnnotatedItem)

isAssignableFrom

public boolean isAssignableFrom(java.util.Set<java.lang.Class<?>> types)
Checks if this item is assignable from any one a set of types

Specified by:
isAssignableFrom in interface AnnotatedItem<T,S>
Parameters:
types - The set of types to check against
Returns:
True if assignable, false otherwise
See Also:
AnnotatedItem.isAssignableFrom(Set)

hashCode

public int hashCode()
Gets the hash code of the actual type

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code

toString

public java.lang.String toString()
Gets a string representation of the item

Overrides:
toString in class java.lang.Object
Returns:
A string representation

toDetailedString

public java.lang.String toDetailedString()

getBindingTypes

public java.util.Set<java.lang.annotation.Annotation> getBindingTypes()
Gets the binding types of the item Looks at the meta-annotations map for annotations with binding type meta-annotation. Returns default binding (current) if none specified.

Specified by:
getBindingTypes in interface AnnotatedItem<T,S>
Returns:
A set of (binding type) annotations
See Also:
AnnotatedItem.getBindingTypes()

getBindingTypesAsArray

public java.lang.annotation.Annotation[] getBindingTypesAsArray()
Gets (as array) the binding types of the item Looks at the meta-annotations map for annotations with binding type meta-annotation. Returns default binding (current) if none specified.

Specified by:
getBindingTypesAsArray in interface AnnotatedItem<T,S>
Returns:
An array of (binding type) annotations
See Also:
AnnotatedItem.getBindingTypesAsArray()

isProxyable

public boolean isProxyable()
Indicates if the type is proxyable to a set of pre-defined rules

Specified by:
isProxyable in interface AnnotatedItem<T,S>
Returns:
True if proxyable, false otherwise.
See Also:
AnnotatedItem.isProxyable()

getDelegate

protected abstract S getDelegate()


Copyright © 2008. All Rights Reserved.