org.codehaus.jackson.map.introspect
Class JacksonAnnotationIntrospector

java.lang.Object
  extended by org.codehaus.jackson.map.AnnotationIntrospector
      extended by org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector

public class JacksonAnnotationIntrospector
extends AnnotationIntrospector

AnnotationIntrospector implementation that handles standard Jackson annotations.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.codehaus.jackson.map.AnnotationIntrospector
AnnotationIntrospector.Pair
 
Constructor Summary
JacksonAnnotationIntrospector()
           
 
Method Summary
 Boolean findCachability(AnnotatedClass ac)
          Method that checks whether specified class has annotations that indicate that it is (or is not) cachable.
 Boolean findCreatorAutoDetection(AnnotatedClass ac)
          Method for checking whether there is a class annotation that indicates whether creator-method auto detection should be enabled.
 String findDeserializablePropertyName(AnnotatedField af)
          Method for checking whether given member field represent a deserializable logical property; and if so, returns the name of that property.
 Class<?> findDeserializationContentType(Annotated am)
          Method for accessing additional narrowing type definition that a method can have, to define more specific content type to use; content refers to Map values and Collection/array elements.
 Class<?> findDeserializationKeyType(Annotated am)
          Method for accessing additional narrowing type definition that a method can have, to define more specific key type to use.
 Class<?> findDeserializationType(Annotated am)
          Method for accessing annotated type definition that a method can have, to be used as the type for serialization instead of the runtime type.
 Class<? extends JsonDeserializer<?>> findDeserializer(Annotated a)
          Method for getting a deserializer definition on specified method or field.
 String findEnumValue(Enum<?> value)
          Method for determining the String value to use for serializing given enumeration entry; used when serializing enumerations as Strings (the standard method).
 Boolean findFieldAutoDetection(AnnotatedClass ac)
          Method for checking whether there is a class annotation that indicates whether field auto detection should be enabled.
 String findGettablePropertyName(AnnotatedMethod am)
          Method for checking whether given method has an annotation that suggests property name associated with method that may be a "getter".
 Boolean findGetterAutoDetection(AnnotatedClass ac)
          Method for checking whether there is a class annotation that indicates whether getter-method auto detection should be enabled.
 String findSerializablePropertyName(AnnotatedField af)
          Method for checking whether given member field represent a serializable logical property; and if so, returns the name of that property.
 JsonSerialize.Inclusion findSerializationInclusion(Annotated a, JsonSerialize.Inclusion defValue)
          Method for checking whether given annotated entity (class, method, field) defines which Bean/Map properties are to be included in serialization.
 Class<?> findSerializationType(Annotated am)
          Method for accessing annotated type definition that a method can have, to be used as the type for serialization instead of the runtime type.
 Class<? extends JsonSerializer<?>> findSerializer(Annotated a)
          Method for getting a serializer definition on specified method or field.
 String findSettablePropertyName(AnnotatedMethod am)
          Method for checking whether given method has an annotation that suggests property name associated with method that may be a "setter".
 Boolean findSetterAutoDetection(AnnotatedClass ac)
          Method for checking whether there is a class annotation that indicates whether setter-method auto detection should be enabled.
 boolean hasAnySetterAnnotation(AnnotatedMethod am)
          Method for checking whether given method has an annotation that suggests that the method is to serve as "any setter"; method to be used for setting values of any properties for which no dedicated setter method is found.
 boolean hasAsValueAnnotation(AnnotatedMethod am)
          Method for checking whether given method has an annotation that suggests that the return value of annotated method should be used as "the value" of the object instance; usually serialized as a primitive value such as String or number.
 boolean hasCreatorAnnotation(AnnotatedMethod am)
          Method for checking whether given method has an annotation that suggests that the method is a "creator" (aka factory) method to be used for construct new instances of deserialized values.
 boolean isHandled(Annotation ann)
          Method called by framework to determine whether given annotation is handled by this introspector.
 boolean isIgnorableField(AnnotatedField f)
          Method for checking whether there is an annotation that indicates that given field should be ignored for all operations (serialization, deserialization).
 boolean isIgnorableMethod(AnnotatedMethod m)
          Method for checking whether there is an annotation that indicates that given method should be ignored for all operations (serialization, deserialization).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JacksonAnnotationIntrospector

public JacksonAnnotationIntrospector()
Method Detail

isHandled

public boolean isHandled(Annotation ann)
Description copied from class: AnnotationIntrospector
Method called by framework to determine whether given annotation is handled by this introspector.

Specified by:
isHandled in class AnnotationIntrospector

findCachability

public Boolean findCachability(AnnotatedClass ac)
Description copied from class: AnnotationIntrospector
Method that checks whether specified class has annotations that indicate that it is (or is not) cachable. Exact semantics depend on type of class annotated and using class (factory or provider).

Currently only used with deserializers, to determine whether provider should cache instances, and if no annotations are found, assumes non-cachable instances.

Specified by:
findCachability in class AnnotationIntrospector
Returns:
True, if class is considered cachable within context; False if not, and null if introspector does not care either way.

findFieldAutoDetection

public Boolean findFieldAutoDetection(AnnotatedClass ac)
Description copied from class: AnnotationIntrospector
Method for checking whether there is a class annotation that indicates whether field auto detection should be enabled.

Specified by:
findFieldAutoDetection in class AnnotationIntrospector
Returns:
null if no relevant annotation is located; Boolean.TRUE if enabling annotation found, Boolean.FALSE if disabling annotation

isIgnorableMethod

public boolean isIgnorableMethod(AnnotatedMethod m)
Description copied from class: AnnotationIntrospector
Method for checking whether there is an annotation that indicates that given method should be ignored for all operations (serialization, deserialization).

Specified by:
isIgnorableMethod in class AnnotationIntrospector
Returns:
True, if an annotation is found to indicate that the method should be ignored; false if not.

isIgnorableField

public boolean isIgnorableField(AnnotatedField f)
Description copied from class: AnnotationIntrospector
Method for checking whether there is an annotation that indicates that given field should be ignored for all operations (serialization, deserialization).

Specified by:
isIgnorableField in class AnnotationIntrospector
Returns:
True, if an annotation is found to indicate that the field should be ignored; false if not.

findSerializer

public Class<? extends JsonSerializer<?>> findSerializer(Annotated a)
Description copied from class: AnnotationIntrospector
Method for getting a serializer definition on specified method or field. Type of definition is either instance (of type JsonSerializer) or Class (of type Class); if value of different type is returned, a runtime exception may be thrown by caller.

Specified by:
findSerializer in class AnnotationIntrospector

findSerializationType

public Class<?> findSerializationType(Annotated am)
Description copied from class: AnnotationIntrospector
Method for accessing annotated type definition that a method can have, to be used as the type for serialization instead of the runtime type. Type returned (if any) needs to be widening conversion (super-type). Declared return type of the method is also considered acceptable.

Specified by:
findSerializationType in class AnnotationIntrospector
Returns:
Class to use instead of runtime type

findSerializationInclusion

public JsonSerialize.Inclusion findSerializationInclusion(Annotated a,
                                                          JsonSerialize.Inclusion defValue)
Description copied from class: AnnotationIntrospector
Method for checking whether given annotated entity (class, method, field) defines which Bean/Map properties are to be included in serialization. If no annotation is found, method should return given second argument; otherwise value indicated by the annotation

Specified by:
findSerializationInclusion in class AnnotationIntrospector
Returns:
Enumerated value indicating which properties to include in serialization

findGetterAutoDetection

public Boolean findGetterAutoDetection(AnnotatedClass ac)
Description copied from class: AnnotationIntrospector
Method for checking whether there is a class annotation that indicates whether getter-method auto detection should be enabled.

Specified by:
findGetterAutoDetection in class AnnotationIntrospector
Returns:
null if no relevant annotation is located; Boolean.TRUE if enabling annotation found, Boolean.FALSE if disabling annotation

findGettablePropertyName

public String findGettablePropertyName(AnnotatedMethod am)
Description copied from class: AnnotationIntrospector
Method for checking whether given method has an annotation that suggests property name associated with method that may be a "getter". Should return null if no annotation is found; otherwise a non-null String. If non-null value is returned, it is used as the property name, except for empty String ("") which is taken to mean "use standard bean name detection if applicable; method name if not".

Specified by:
findGettablePropertyName in class AnnotationIntrospector

hasAsValueAnnotation

public boolean hasAsValueAnnotation(AnnotatedMethod am)
Description copied from class: AnnotationIntrospector
Method for checking whether given method has an annotation that suggests that the return value of annotated method should be used as "the value" of the object instance; usually serialized as a primitive value such as String or number.

Specified by:
hasAsValueAnnotation in class AnnotationIntrospector
Returns:
True if such annotation is found (and is not disabled); false if no enabled annotation is found

findEnumValue

public String findEnumValue(Enum<?> value)
Description copied from class: AnnotationIntrospector
Method for determining the String value to use for serializing given enumeration entry; used when serializing enumerations as Strings (the standard method).

Specified by:
findEnumValue in class AnnotationIntrospector
Returns:
Serialized enum value.

findSerializablePropertyName

public String findSerializablePropertyName(AnnotatedField af)
Description copied from class: AnnotationIntrospector
Method for checking whether given member field represent a serializable logical property; and if so, returns the name of that property. Should return null if no annotation is found (indicating it is not a serializable field); otherwise a non-null String. If non-null value is returned, it is used as the property name, except for empty String ("") which is taken to mean "use the field name as is".

Specified by:
findSerializablePropertyName in class AnnotationIntrospector

findDeserializer

public Class<? extends JsonDeserializer<?>> findDeserializer(Annotated a)
Description copied from class: AnnotationIntrospector
Method for getting a deserializer definition on specified method or field. Type of definition is either instance (of type JsonDeserializer) or Class (of type Class); if value of different type is returned, a runtime exception may be thrown by caller.

Specified by:
findDeserializer in class AnnotationIntrospector

findDeserializationType

public Class<?> findDeserializationType(Annotated am)
Description copied from class: AnnotationIntrospector
Method for accessing annotated type definition that a method can have, to be used as the type for serialization instead of the runtime type. Type must be a narrowing conversion (i.e.subtype of declared type). Declared return type of the method is also considered acceptable.

Specified by:
findDeserializationType in class AnnotationIntrospector
Returns:
Class to use for deserialization instead of declared type

findDeserializationKeyType

public Class<?> findDeserializationKeyType(Annotated am)
Description copied from class: AnnotationIntrospector
Method for accessing additional narrowing type definition that a method can have, to define more specific key type to use. It should be only be used with Map types.

Specified by:
findDeserializationKeyType in class AnnotationIntrospector
Returns:
Class specifying more specific type to use instead of declared type, if annotation found; null if not

findDeserializationContentType

public Class<?> findDeserializationContentType(Annotated am)
Description copied from class: AnnotationIntrospector
Method for accessing additional narrowing type definition that a method can have, to define more specific content type to use; content refers to Map values and Collection/array elements. It should be only be used with Map, Collection and array types.

Specified by:
findDeserializationContentType in class AnnotationIntrospector
Returns:
Class specifying more specific type to use instead of declared type, if annotation found; null if not

findCreatorAutoDetection

public Boolean findCreatorAutoDetection(AnnotatedClass ac)
Description copied from class: AnnotationIntrospector
Method for checking whether there is a class annotation that indicates whether creator-method auto detection should be enabled.

Specified by:
findCreatorAutoDetection in class AnnotationIntrospector
Returns:
null if no relevant annotation is located; Boolean.TRUE if enabling annotation found, Boolean.FALSE if disabling annotation

findSetterAutoDetection

public Boolean findSetterAutoDetection(AnnotatedClass ac)
Description copied from class: AnnotationIntrospector
Method for checking whether there is a class annotation that indicates whether setter-method auto detection should be enabled.

Specified by:
findSetterAutoDetection in class AnnotationIntrospector
Returns:
null if no relevant annotation is located; Boolean.TRUE if enabling annotation found, Boolean.FALSE if disabling annotation

findSettablePropertyName

public String findSettablePropertyName(AnnotatedMethod am)
Description copied from class: AnnotationIntrospector
Method for checking whether given method has an annotation that suggests property name associated with method that may be a "setter". Should return null if no annotation is found; otherwise a non-null String. If non-null value is returned, it is used as the property name, except for empty String ("") which is taken to mean "use standard bean name detection if applicable; method name if not".

Specified by:
findSettablePropertyName in class AnnotationIntrospector

hasAnySetterAnnotation

public boolean hasAnySetterAnnotation(AnnotatedMethod am)
Description copied from class: AnnotationIntrospector
Method for checking whether given method has an annotation that suggests that the method is to serve as "any setter"; method to be used for setting values of any properties for which no dedicated setter method is found.

Specified by:
hasAnySetterAnnotation in class AnnotationIntrospector
Returns:
True if such annotation is found (and is not disabled), false otherwise

hasCreatorAnnotation

public boolean hasCreatorAnnotation(AnnotatedMethod am)
Description copied from class: AnnotationIntrospector
Method for checking whether given method has an annotation that suggests that the method is a "creator" (aka factory) method to be used for construct new instances of deserialized values.

Specified by:
hasCreatorAnnotation in class AnnotationIntrospector
Returns:
True if such annotation is found (and is not disabled), false otherwise

findDeserializablePropertyName

public String findDeserializablePropertyName(AnnotatedField af)
Description copied from class: AnnotationIntrospector
Method for checking whether given member field represent a deserializable logical property; and if so, returns the name of that property. Should return null if no annotation is found (indicating it is not a deserializable field); otherwise a non-null String. If non-null value is returned, it is used as the property name, except for empty String ("") which is taken to mean "use the field name as is".

Specified by:
findDeserializablePropertyName in class AnnotationIntrospector