Class RuntimeInlineAnnotationReader
- java.lang.Object
-
- com.sun.xml.bind.v2.model.annotation.AbstractInlineAnnotationReaderImpl<Type,Class,Field,Method>
-
- com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader
-
- All Implemented Interfaces:
AnnotationReader<Type,Class,Field,Method>
,RuntimeAnnotationReader
public final class RuntimeInlineAnnotationReader extends AbstractInlineAnnotationReaderImpl<Type,Class,Field,Method> implements RuntimeAnnotationReader
AnnotationReader
that usesjava.lang.reflect
to read annotations from class files.- Author:
- Kohsuke Kawaguchi ([email protected])
-
-
Constructor Summary
Constructors Constructor Description RuntimeInlineAnnotationReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
fullName(Method m)
Gets the fully-qualified name of the method.Annotation[]
getAllFieldAnnotations(Field field, Locatable srcPos)
Gets all the annotations on a field.Annotation[]
getAllMethodAnnotations(Method method, Locatable srcPos)
Gets all the annotations on a method.<A extends Annotation>
AgetClassAnnotation(Class<A> a, Class clazz, Locatable srcPos)
Reads an annotation on a class.Class[]
getClassArrayValue(Annotation a, String name)
Similar toAnnotationReader.getClassValue(Annotation, String)
method but obtains an array parameter.Class
getClassValue(Annotation a, String name)
Reads a value of an annotation that returns a Class object.<A extends Annotation>
AgetFieldAnnotation(Class<A> annotation, Field field, Locatable srcPos)
Reads an annotation on a property that consists of a field.<A extends Annotation>
AgetMethodAnnotation(Class<A> annotation, Method method, Locatable srcPos)
<A extends Annotation>
AgetMethodParameterAnnotation(Class<A> annotation, Method method, int paramIndex, Locatable srcPos)
Reads an annotation on a parameter of the method.<A extends Annotation>
AgetPackageAnnotation(Class<A> a, Class clazz, Locatable srcPos)
Reads an annotation on the package that the given class belongs to.boolean
hasClassAnnotation(Class clazz, Class<? extends Annotation> annotationType)
Checks if a class has the annotation.boolean
hasFieldAnnotation(Class<? extends Annotation> annotationType, Field field)
Checks if the given field has an annotation.boolean
hasMethodAnnotation(Class<? extends Annotation> annotation, Method method)
-
Methods inherited from class com.sun.xml.bind.v2.model.annotation.AbstractInlineAnnotationReaderImpl
getErrorHandler, getMethodAnnotation, hasMethodAnnotation, setErrorHandler
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.sun.xml.bind.v2.model.annotation.AnnotationReader
getMethodAnnotation, hasMethodAnnotation, setErrorHandler
-
-
-
-
Method Detail
-
getFieldAnnotation
public <A extends Annotation> A getFieldAnnotation(Class<A> annotation, Field field, Locatable srcPos)
Description copied from interface:AnnotationReader
Reads an annotation on a property that consists of a field.- Specified by:
getFieldAnnotation
in interfaceAnnotationReader<Type,Class,Field,Method>
-
hasFieldAnnotation
public boolean hasFieldAnnotation(Class<? extends Annotation> annotationType, Field field)
Description copied from interface:AnnotationReader
Checks if the given field has an annotation.- Specified by:
hasFieldAnnotation
in interfaceAnnotationReader<Type,Class,Field,Method>
-
hasClassAnnotation
public boolean hasClassAnnotation(Class clazz, Class<? extends Annotation> annotationType)
Description copied from interface:AnnotationReader
Checks if a class has the annotation.- Specified by:
hasClassAnnotation
in interfaceAnnotationReader<Type,Class,Field,Method>
-
getAllFieldAnnotations
public Annotation[] getAllFieldAnnotations(Field field, Locatable srcPos)
Description copied from interface:AnnotationReader
Gets all the annotations on a field.- Specified by:
getAllFieldAnnotations
in interfaceAnnotationReader<Type,Class,Field,Method>
-
getMethodAnnotation
public <A extends Annotation> A getMethodAnnotation(Class<A> annotation, Method method, Locatable srcPos)
- Specified by:
getMethodAnnotation
in interfaceAnnotationReader<Type,Class,Field,Method>
-
hasMethodAnnotation
public boolean hasMethodAnnotation(Class<? extends Annotation> annotation, Method method)
- Specified by:
hasMethodAnnotation
in interfaceAnnotationReader<Type,Class,Field,Method>
-
getAllMethodAnnotations
public Annotation[] getAllMethodAnnotations(Method method, Locatable srcPos)
Description copied from interface:AnnotationReader
Gets all the annotations on a method.- Specified by:
getAllMethodAnnotations
in interfaceAnnotationReader<Type,Class,Field,Method>
srcPos
- the location from which this annotation is read.
-
getMethodParameterAnnotation
public <A extends Annotation> A getMethodParameterAnnotation(Class<A> annotation, Method method, int paramIndex, Locatable srcPos)
Description copied from interface:AnnotationReader
Reads an annotation on a parameter of the method.- Specified by:
getMethodParameterAnnotation
in interfaceAnnotationReader<Type,Class,Field,Method>
- Returns:
- null if the annotation was not found.
-
getClassAnnotation
public <A extends Annotation> A getClassAnnotation(Class<A> a, Class clazz, Locatable srcPos)
Description copied from interface:AnnotationReader
Reads an annotation on a class.- Specified by:
getClassAnnotation
in interfaceAnnotationReader<Type,Class,Field,Method>
-
getPackageAnnotation
public <A extends Annotation> A getPackageAnnotation(Class<A> a, Class clazz, Locatable srcPos)
Description copied from interface:AnnotationReader
Reads an annotation on the package that the given class belongs to.- Specified by:
getPackageAnnotation
in interfaceAnnotationReader<Type,Class,Field,Method>
-
getClassValue
public Class getClassValue(Annotation a, String name)
Description copied from interface:AnnotationReader
Reads a value of an annotation that returns a Class object.Depending on the underlying reflection library, you can't always obtain the
Class
object directly (see the Annotation Processing MirrorTypeException for example), so use this method to avoid that.- Specified by:
getClassValue
in interfaceAnnotationReader<Type,Class,Field,Method>
name
- The name of the annotation parameter to be read.
-
getClassArrayValue
public Class[] getClassArrayValue(Annotation a, String name)
Description copied from interface:AnnotationReader
Similar toAnnotationReader.getClassValue(Annotation, String)
method but obtains an array parameter.- Specified by:
getClassArrayValue
in interfaceAnnotationReader<Type,Class,Field,Method>
-
fullName
protected String fullName(Method m)
Description copied from class:AbstractInlineAnnotationReaderImpl
Gets the fully-qualified name of the method. Used for error messages.
-
-