public final class AnnotatedClass extends Annotated implements TypeResolutionContext
TypeResolutionContext.Basic
Modifier and Type | Field and Description |
---|---|
protected AnnotationIntrospector |
_annotationIntrospector
Filter used to determine which annotations to gather; used
to optimize things so that unnecessary annotations are
ignored.
|
protected TypeBindings |
_bindings
Type bindings to use for members of
_class . |
protected java.lang.Class<?> |
_class
Class for which annotations apply, and that owns other
components (constructors, methods)
|
protected AnnotationMap |
_classAnnotations
Combined list of Jackson annotations that the class has,
including inheritable ones from super classes and interfaces
|
protected java.util.List<AnnotatedConstructor> |
_constructors
Single argument constructors the class has, if any.
|
protected java.util.List<AnnotatedMethod> |
_creatorMethods
Single argument static methods that might be usable
as factory methods
|
protected boolean |
_creatorsResolved
Flag to indicate whether creator information has been resolved
or not.
|
protected AnnotatedConstructor |
_defaultConstructor
Default constructor of the annotated class, if it has one.
|
protected java.util.List<AnnotatedField> |
_fields
Member fields of interest: ones that are either public,
or have at least one annotation.
|
protected AnnotatedMethodMap |
_memberMethods
Member methods of interest; for now ones with 0 or 1 arguments
(just optimization, since others won't be used now)
|
protected ClassIntrospector.MixInResolver |
_mixInResolver
Object that knows mapping of mix-in classes (ones that contain
annotations to add) with their target classes (ones that
get these additional annotations "mixed in").
|
protected java.lang.Class<?> |
_primaryMixIn
Primary mix-in class; one to use for the annotated class
itself.
|
protected java.util.List<JavaType> |
_superTypes
Ordered set of super classes and interfaces of the
class itself: included in order of precedence
|
protected JavaType |
_type |
protected TypeFactory |
_typeFactory |
private static AnnotationMap[] |
NO_ANNOTATION_MAPS |
Modifier | Constructor and Description |
---|---|
private |
AnnotatedClass(JavaType type,
java.lang.Class<?> rawType,
TypeBindings bindings,
java.util.List<JavaType> superTypes,
AnnotationIntrospector aintr,
ClassIntrospector.MixInResolver mir,
TypeFactory tf,
AnnotationMap classAnnotations)
Constructor will not do any initializations, to allow for
configuring instances differently depending on use cases
|
Modifier and Type | Method and Description |
---|---|
private void |
_addAnnotationsIfNotPresent(AnnotatedMember target,
java.lang.annotation.Annotation[] anns) |
private AnnotationMap |
_addAnnotationsIfNotPresent(AnnotationMap result,
java.lang.annotation.Annotation[] anns) |
protected void |
_addClassMixIns(AnnotationMap annotations,
java.lang.Class<?> target) |
protected void |
_addClassMixIns(AnnotationMap annotations,
java.lang.Class<?> toMask,
java.lang.Class<?> mixin) |
protected void |
_addClassMixIns(AnnotationMap annotations,
JavaType target)
Helper method for adding any mix-in annotations specified
class might have.
|
protected void |
_addConstructorMixIns(java.lang.Class<?> mixin) |
protected void |
_addFactoryMixIns(java.lang.Class<?> mixin) |
protected void |
_addFieldMixIns(java.lang.Class<?> mixInCls,
java.lang.Class<?> targetClass,
java.util.Map<java.lang.String,AnnotatedField> fields)
Method called to add field mix-ins from given mix-in class (and its fields)
into already collected actual fields (from introspected classes and their
super-classes)
|
private java.util.List<java.lang.annotation.Annotation> |
_addFromBundle(java.lang.annotation.Annotation bundle,
java.util.List<java.lang.annotation.Annotation> result) |
protected void |
_addMemberMethods(java.lang.Class<?> cls,
TypeResolutionContext typeContext,
AnnotatedMethodMap methods,
java.lang.Class<?> mixInCls,
AnnotatedMethodMap mixIns) |
protected void |
_addMethodMixIns(java.lang.Class<?> targetClass,
AnnotatedMethodMap methods,
java.lang.Class<?> mixInCls,
AnnotatedMethodMap mixIns) |
protected void |
_addMixOvers(java.lang.reflect.Constructor<?> mixin,
AnnotatedConstructor target,
boolean addParamAnnotations) |
protected void |
_addMixOvers(java.lang.reflect.Method mixin,
AnnotatedMethod target,
boolean addParamAnnotations) |
protected void |
_addMixUnders(java.lang.reflect.Method src,
AnnotatedMethod target)
Method that will add annotations from specified source method to target method,
but only if target does not yet have them.
|
private void |
_addOrOverrideAnnotations(AnnotatedMember target,
java.lang.annotation.Annotation[] anns) |
private AnnotationMap |
_classAnnotations() |
protected AnnotationMap |
_collectRelevantAnnotations(java.lang.annotation.Annotation[] anns) |
protected AnnotationMap[] |
_collectRelevantAnnotations(java.lang.annotation.Annotation[][] anns) |
protected AnnotatedMethod |
_constructCreatorMethod(java.lang.reflect.Method m,
TypeResolutionContext typeContext) |
protected AnnotatedConstructor |
_constructDefaultConstructor(ClassUtil.Ctor ctor,
TypeResolutionContext typeContext) |
protected AnnotatedField |
_constructField(java.lang.reflect.Field f,
TypeResolutionContext typeContext) |
protected AnnotatedMethod |
_constructMethod(java.lang.reflect.Method m,
TypeResolutionContext typeContext) |
protected AnnotatedConstructor |
_constructNonDefaultConstructor(ClassUtil.Ctor ctor,
TypeResolutionContext typeContext) |
private AnnotationMap |
_emptyAnnotationMap() |
private AnnotationMap[] |
_emptyAnnotationMaps(int count) |
protected java.lang.reflect.Method[] |
_findClassMethods(java.lang.Class<?> cls)
Helper method that gets methods declared in given class; usually a simple thing,
but sometimes (as per [databind#785]) more complicated, depending on classloader
setup.
|
protected java.util.Map<java.lang.String,AnnotatedField> |
_findFields(JavaType type,
TypeResolutionContext typeContext,
java.util.Map<java.lang.String,AnnotatedField> fields) |
private boolean |
_isAnnotationBundle(java.lang.annotation.Annotation ann) |
private boolean |
_isIncludableConstructor(java.lang.reflect.Constructor<?> c) |
private boolean |
_isIncludableField(java.lang.reflect.Field f) |
protected boolean |
_isIncludableMemberMethod(java.lang.reflect.Method m) |
private AnnotationMap |
_resolveClassAnnotations()
Initialization method that will recursively collect Jackson
annotations for this class and all super classes and
interfaces.
|
java.lang.Iterable<java.lang.annotation.Annotation> |
annotations()
Accessor that can be used to iterate over all the annotations
associated with annotated component.
|
static AnnotatedClass |
construct(JavaType type,
MapperConfig<?> config)
Factory method that instantiates an instance.
|
static AnnotatedClass |
construct(JavaType type,
MapperConfig<?> config,
ClassIntrospector.MixInResolver mir) |
static AnnotatedClass |
constructWithoutSuperTypes(java.lang.Class<?> cls,
MapperConfig<?> config)
Method similar to
construct(com.fasterxml.jackson.databind.JavaType, com.fasterxml.jackson.databind.cfg.MapperConfig<?>) , but that will NOT include
information from supertypes; only class itself and any direct
mix-ins it may have. |
static AnnotatedClass |
constructWithoutSuperTypes(java.lang.Class<?> cls,
MapperConfig<?> config,
ClassIntrospector.MixInResolver mir) |
boolean |
equals(java.lang.Object o) |
java.lang.Iterable<AnnotatedField> |
fields() |
AnnotatedMethod |
findMethod(java.lang.String name,
java.lang.Class<?>[] paramTypes) |
protected AnnotationMap |
getAllAnnotations()
Internal helper method used to access annotation information;
not exposed to developers since instances are mutable.
|
java.lang.Class<?> |
getAnnotated()
Method that can be used to find actual JDK element that this instance
represents.
|
<A extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class<A> acls) |
Annotations |
getAnnotations() |
java.util.List<AnnotatedConstructor> |
getConstructors() |
AnnotatedConstructor |
getDefaultConstructor() |
int |
getFieldCount() |
int |
getMemberMethodCount() |
int |
getModifiers() |
java.lang.String |
getName() |
java.lang.Class<?> |
getRawType()
"Raw" type (type-erased class) of the annotated element; definition
of what exactly this means depends on sub-class.
|
java.util.List<AnnotatedMethod> |
getStaticMethods() |
JavaType |
getType()
Full generic type of the annotated element; definition
of what exactly this means depends on sub-class.
|
boolean |
hasAnnotation(java.lang.Class<?> acls) |
boolean |
hasAnnotations() |
int |
hashCode() |
boolean |
hasOneOf(java.lang.Class<? extends java.lang.annotation.Annotation>[] annoClasses) |
java.lang.Iterable<AnnotatedMethod> |
memberMethods() |
private void |
resolveCreators()
Initialization method that will find out all constructors
and potential static factory methods the class has.
|
private void |
resolveFields()
Method that will collect all member (non-static) fields
that are either public, or have at least a single annotation
associated with them.
|
private void |
resolveMemberMethods()
Method for resolving member method information: aggregating all non-static methods
and combining annotations (to implement method-annotation inheritance)
|
JavaType |
resolveType(java.lang.reflect.Type type) |
java.lang.String |
toString() |
AnnotatedClass |
withAnnotations(AnnotationMap ann)
Fluent factory method that will construct a new instance that uses specified
instance annotations instead of currently configured ones.
|
getGenericType, getType, isPublic, withFallBackAnnotationsFrom
private static final AnnotationMap[] NO_ANNOTATION_MAPS
protected final JavaType _type
protected final java.lang.Class<?> _class
protected final TypeBindings _bindings
_class
.protected final java.util.List<JavaType> _superTypes
NOTE: changed in 2.7 from List of Class
es to List of JavaType
s.
protected final AnnotationIntrospector _annotationIntrospector
protected final TypeFactory _typeFactory
protected final ClassIntrospector.MixInResolver _mixInResolver
protected final java.lang.Class<?> _primaryMixIn
protected AnnotationMap _classAnnotations
protected boolean _creatorsResolved
protected AnnotatedConstructor _defaultConstructor
protected java.util.List<AnnotatedConstructor> _constructors
protected java.util.List<AnnotatedMethod> _creatorMethods
protected AnnotatedMethodMap _memberMethods
protected java.util.List<AnnotatedField> _fields
private AnnotatedClass(JavaType type, java.lang.Class<?> rawType, TypeBindings bindings, java.util.List<JavaType> superTypes, AnnotationIntrospector aintr, ClassIntrospector.MixInResolver mir, TypeFactory tf, AnnotationMap classAnnotations)
public AnnotatedClass withAnnotations(AnnotationMap ann)
Annotated
withAnnotations
in class Annotated
public static AnnotatedClass construct(JavaType type, MapperConfig<?> config)
public static AnnotatedClass construct(JavaType type, MapperConfig<?> config, ClassIntrospector.MixInResolver mir)
public static AnnotatedClass constructWithoutSuperTypes(java.lang.Class<?> cls, MapperConfig<?> config)
construct(com.fasterxml.jackson.databind.JavaType, com.fasterxml.jackson.databind.cfg.MapperConfig<?>)
, but that will NOT include
information from supertypes; only class itself and any direct
mix-ins it may have.public static AnnotatedClass constructWithoutSuperTypes(java.lang.Class<?> cls, MapperConfig<?> config, ClassIntrospector.MixInResolver mir)
public JavaType resolveType(java.lang.reflect.Type type)
resolveType
in interface TypeResolutionContext
public java.lang.Class<?> getAnnotated()
Annotated
getAnnotated
in class Annotated
public int getModifiers()
getModifiers
in class Annotated
public <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.Class<A> acls)
getAnnotation
in class Annotated
public boolean hasAnnotation(java.lang.Class<?> acls)
hasAnnotation
in class Annotated
public boolean hasOneOf(java.lang.Class<? extends java.lang.annotation.Annotation>[] annoClasses)
public java.lang.Class<?> getRawType()
Annotated
getRawType
in class Annotated
public java.lang.Iterable<java.lang.annotation.Annotation> annotations()
Annotated
annotations
in class Annotated
protected AnnotationMap getAllAnnotations()
Annotated
getAllAnnotations
in class Annotated
public JavaType getType()
Annotated
public Annotations getAnnotations()
public boolean hasAnnotations()
public AnnotatedConstructor getDefaultConstructor()
public java.util.List<AnnotatedConstructor> getConstructors()
public java.util.List<AnnotatedMethod> getStaticMethods()
public java.lang.Iterable<AnnotatedMethod> memberMethods()
public int getMemberMethodCount()
public AnnotatedMethod findMethod(java.lang.String name, java.lang.Class<?>[] paramTypes)
public int getFieldCount()
public java.lang.Iterable<AnnotatedField> fields()
private AnnotationMap _classAnnotations()
private AnnotationMap _resolveClassAnnotations()
private void resolveCreators()
private void resolveMemberMethods()
methodFilter
- Filter used to determine which methods to includeprivate void resolveFields()
protected void _addClassMixIns(AnnotationMap annotations, JavaType target)
protected void _addClassMixIns(AnnotationMap annotations, java.lang.Class<?> target)
protected void _addClassMixIns(AnnotationMap annotations, java.lang.Class<?> toMask, java.lang.Class<?> mixin)
protected void _addConstructorMixIns(java.lang.Class<?> mixin)
protected void _addFactoryMixIns(java.lang.Class<?> mixin)
protected void _addMemberMethods(java.lang.Class<?> cls, TypeResolutionContext typeContext, AnnotatedMethodMap methods, java.lang.Class<?> mixInCls, AnnotatedMethodMap mixIns)
protected void _addMethodMixIns(java.lang.Class<?> targetClass, AnnotatedMethodMap methods, java.lang.Class<?> mixInCls, AnnotatedMethodMap mixIns)
protected java.util.Map<java.lang.String,AnnotatedField> _findFields(JavaType type, TypeResolutionContext typeContext, java.util.Map<java.lang.String,AnnotatedField> fields)
protected void _addFieldMixIns(java.lang.Class<?> mixInCls, java.lang.Class<?> targetClass, java.util.Map<java.lang.String,AnnotatedField> fields)
protected AnnotatedMethod _constructMethod(java.lang.reflect.Method m, TypeResolutionContext typeContext)
protected AnnotatedConstructor _constructDefaultConstructor(ClassUtil.Ctor ctor, TypeResolutionContext typeContext)
protected AnnotatedConstructor _constructNonDefaultConstructor(ClassUtil.Ctor ctor, TypeResolutionContext typeContext)
protected AnnotatedMethod _constructCreatorMethod(java.lang.reflect.Method m, TypeResolutionContext typeContext)
protected AnnotatedField _constructField(java.lang.reflect.Field f, TypeResolutionContext typeContext)
private AnnotationMap _emptyAnnotationMap()
private AnnotationMap[] _emptyAnnotationMaps(int count)
protected boolean _isIncludableMemberMethod(java.lang.reflect.Method m)
private boolean _isIncludableField(java.lang.reflect.Field f)
private boolean _isIncludableConstructor(java.lang.reflect.Constructor<?> c)
protected AnnotationMap[] _collectRelevantAnnotations(java.lang.annotation.Annotation[][] anns)
protected AnnotationMap _collectRelevantAnnotations(java.lang.annotation.Annotation[] anns)
private AnnotationMap _addAnnotationsIfNotPresent(AnnotationMap result, java.lang.annotation.Annotation[] anns)
private java.util.List<java.lang.annotation.Annotation> _addFromBundle(java.lang.annotation.Annotation bundle, java.util.List<java.lang.annotation.Annotation> result)
private void _addAnnotationsIfNotPresent(AnnotatedMember target, java.lang.annotation.Annotation[] anns)
private void _addOrOverrideAnnotations(AnnotatedMember target, java.lang.annotation.Annotation[] anns)
protected void _addMixOvers(java.lang.reflect.Constructor<?> mixin, AnnotatedConstructor target, boolean addParamAnnotations)
addParamAnnotations
- Whether parameter annotations are to be
added as wellprotected void _addMixOvers(java.lang.reflect.Method mixin, AnnotatedMethod target, boolean addParamAnnotations)
addParamAnnotations
- Whether parameter annotations are to be
added as wellprotected void _addMixUnders(java.lang.reflect.Method src, AnnotatedMethod target)
private final boolean _isAnnotationBundle(java.lang.annotation.Annotation ann)
protected java.lang.reflect.Method[] _findClassMethods(java.lang.Class<?> cls)