下面列出了怎么用com.fasterxml.jackson.databind.util.Annotations的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* @deprecated Since 2.9
*/
@Deprecated
public Std(PropertyName name, JavaType type, PropertyName wrapperName,
Annotations contextAnnotations,
AnnotatedMember member, PropertyMetadata metadata)
{
this(name, type, wrapperName, member, metadata);
}
@Deprecated // Since 2.9
public BeanPropertyWriter(BeanPropertyDefinition propDef,
AnnotatedMember member, Annotations contextAnnotations,
JavaType declaredType,
JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType,
boolean suppressNulls, Object suppressableValue)
{
this(propDef, member, contextAnnotations, declaredType,
ser, typeSer, serType, suppressNulls, suppressableValue,
null);
}
protected AttributePropertyWriter(String attrName, BeanPropertyDefinition propDef,
Annotations contextAnnotations, JavaType declaredType,
JsonInclude.Value inclusion)
{
super(propDef, contextAnnotations, declaredType,
/* value serializer */ null, /* type serializer */ null, /* ser type */ null,
inclusion,
// 10-Oct-2016, tatu: Could enable per-view settings too in future
null);
_attrName = attrName;
}
public static AttributePropertyWriter construct(String attrName,
BeanPropertyDefinition propDef,
Annotations contextAnnotations,
JavaType declaredType)
{
return new AttributePropertyWriter(attrName, propDef,
contextAnnotations, declaredType);
}
/**
* Constructor used by most sub-types.
*/
protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef,
Annotations contextAnnotations, JavaType declaredType)
{
this(propDef, contextAnnotations, declaredType, null, null, null,
propDef.findInclusion());
}
/**
* Pass-through constructor that may be used by sub-classes that
* want full control over implementation.
*/
protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef,
Annotations contextAnnotations, JavaType declaredType,
JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType,
JsonInclude.Value inclusion, Class<?>[] includeInViews)
{
super(propDef, propDef.getPrimaryMember(), contextAnnotations, declaredType,
ser, typeSer, serType,
_suppressNulls(inclusion), _suppressableValue(inclusion),
includeInViews);
}
@Deprecated // since 2.8
protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef,
Annotations contextAnnotations, JavaType declaredType,
JsonSerializer<?> ser, TypeSerializer typeSer, JavaType serType,
JsonInclude.Value inclusion)
{
this(propDef, contextAnnotations, declaredType, ser, typeSer, serType, inclusion, null);
}
/**
* Constructor will not do any initializations, to allow for
* configuring instances differently depending on use cases
*
* @param type Fully resolved type; may be `null`, but ONLY if no member fields or
* methods are to be accessed
* @param rawType Type-erased class; pass if no `type` needed or available
*/
AnnotatedClass(JavaType type, Class<?> rawType, List<JavaType> superTypes,
Class<?> primaryMixIn, Annotations classAnnotations, TypeBindings bindings,
AnnotationIntrospector aintr, MixInResolver mir, TypeFactory tf)
{
_type = type;
_class = rawType;
_superTypes = superTypes;
_primaryMixIn = primaryMixIn;
_classAnnotations = classAnnotations;
_bindings = bindings;
_annotationIntrospector = aintr;
_mixInResolver = mir;
_typeFactory = tf;
}
@Override
public Annotations asAnnotations() {
if (_annotations.size() == 2) {
Iterator<Map.Entry<Class<?>,Annotation>> it = _annotations.entrySet().iterator();
Map.Entry<Class<?>,Annotation> en1 = it.next(), en2 = it.next();
return new TwoAnnotations(en1.getKey(), en1.getValue(),
en2.getKey(), en2.getValue());
}
return new AnnotationMap(_annotations);
}
/**
* Initialization method that will recursively collect Jackson
* annotations for this class and all super classes and
* interfaces.
*/
private Annotations resolveClassAnnotations(List<JavaType> superTypes)
{
// Should skip processing if annotation processing disabled
if (_intr == null) {
return NO_ANNOTATIONS;
}
AnnotationCollector resolvedCA = AnnotationCollector.emptyCollector();
// add mix-in annotations first (overrides)
if (_primaryMixin != null) {
resolvedCA = _addClassMixIns(resolvedCA, _class, _primaryMixin);
}
// then annotations from the class itself:
resolvedCA = _addAnnotationsIfNotPresent(resolvedCA,
ClassUtil.findClassAnnotations(_class));
// and then from super types
for (JavaType type : superTypes) {
// and mix mix-in annotations in-between
if (_mixInResolver != null) {
Class<?> cls = type.getRawClass();
resolvedCA = _addClassMixIns(resolvedCA, cls,
_mixInResolver.findMixInClassFor(cls));
}
resolvedCA = _addAnnotationsIfNotPresent(resolvedCA,
ClassUtil.findClassAnnotations(type.getRawClass()));
}
/* and finally... any annotations there might be for plain
* old Object.class: separate because for all other purposes
* it is just ignored (not included in super types)
*/
// 12-Jul-2009, tatu: Should this be done for interfaces too?
// For now, yes, seems useful for some cases, and not harmful for any?
if (_mixInResolver != null) {
resolvedCA = _addClassMixIns(resolvedCA, Object.class,
_mixInResolver.findMixInClassFor(Object.class));
}
return resolvedCA.asAnnotations();
}
protected SettableBeanProperty(PropertyName propName, JavaType type, PropertyName wrapper,
TypeDeserializer typeDeser, Annotations contextAnnotations,
PropertyMetadata metadata)
{
super(metadata);
// 09-Jan-2009, tatu: Intern()ing makes sense since Jackson parsed
// field names are (usually) interned too, hence lookups will be faster.
// 23-Oct-2009, tatu: should this be disabled wrt [JACKSON-180]?
// Probably need not, given that namespace of field/method names
// is not unbounded, unlike potential JSON names.
if (propName == null) {
_propName = PropertyName.NO_NAME;
} else {
_propName = propName.internSimpleName();
}
_type = type;
_wrapperName = wrapper;
_contextAnnotations = contextAnnotations;
_viewMatcher = null;
// 30-Jan-2012, tatu: Important: contextualize TypeDeserializer now...
if (typeDeser != null) {
typeDeser = typeDeser.forProperty(this);
}
_valueTypeDeserializer = typeDeser;
_valueDeserializer = MISSING_VALUE_DESERIALIZER;
_nullProvider = MISSING_VALUE_DESERIALIZER;
}
public void addInjectable(PropertyName propName, JavaType propType,
Annotations contextAnnotations, AnnotatedMember member,
Object valueId)
{
if (_injectables == null) {
_injectables = new ArrayList<ValueInjector>();
}
boolean fixAccess = _config.canOverrideAccessModifiers();
boolean forceAccess = fixAccess && _config.isEnabled(MapperFeature.OVERRIDE_PUBLIC_ACCESS_MODIFIERS);
if (fixAccess) {
member.fixAccess(forceAccess);
}
_injectables.add(new ValueInjector(propName, propType, member, valueId));
}
public FieldProperty(BeanPropertyDefinition propDef, JavaType type,
TypeDeserializer typeDeser, Annotations contextAnnotations, AnnotatedField field)
{
super(propDef, type, typeDeser, contextAnnotations);
_annotated = field;
_field = field.getAnnotated();
_skipNulls = NullsConstantProvider.isSkipper(_nullProvider);
}
public MethodProperty(BeanPropertyDefinition propDef,
JavaType type, TypeDeserializer typeDeser,
Annotations contextAnnotations, AnnotatedMethod method)
{
super(propDef, type, typeDeser, contextAnnotations);
_annotated = method;
_setter = method.getAnnotated();
_skipNulls = NullsConstantProvider.isSkipper(_nullProvider);
}
public SetterlessProperty(BeanPropertyDefinition propDef, JavaType type,
TypeDeserializer typeDeser, Annotations contextAnnotations, AnnotatedMethod method)
{
super(propDef, type, typeDeser, contextAnnotations);
_annotated = method;
_getter = method.getAnnotated();
}
/**
* This constructor should not be invoked directly and should only be used within
* {@link #withConfig(MapperConfig, AnnotatedClass, BeanPropertyDefinition, JavaType)} call.
*
* @param propDef property definition created by {@code by com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector}
* @param annotations contains only @JsonAppend at the moment
* @param type {@link VirtualProperty}[]
* @param virtualProperties {@link VirtualProperty}-ies to append
* @param valueResolver {@link ValueResolver} dynamic variables resolver
* @param filters {@link VirtualPropertyFilter} inclusion filters. Allow to include/exclude
* {@link VirtualProperty} by name or value returned by {@link ValueResolver}
*/
VirtualPropertiesWriter(
BeanPropertyDefinition propDef,
Annotations annotations,
JavaType type,
VirtualProperty[] virtualProperties,
ValueResolver valueResolver,
VirtualPropertyFilter[] filters
) {
super(propDef, annotations, type);
this.virtualProperties = virtualProperties;
this.valueResolver = valueResolver;
this.filters = filters;
}
protected AttributePropertyWriter(String attrName, BeanPropertyDefinition propDef,
Annotations contextAnnotations, JavaType declaredType) {
this(attrName, propDef, contextAnnotations, declaredType, propDef.findInclusion());
}
@Override
public Annotations getClassAnnotations() {
return _classInfo.getAnnotations();
}
public Annotations getAnnotations() {
return _classAnnotations;
}
@Override
public Annotations asAnnotations() {
return NO_ANNOTATIONS;
}
@Override
public Annotations asAnnotations() {
return new OneAnnotation(_type, _value);
}
protected SettableBeanProperty(BeanPropertyDefinition propDef,
JavaType type, TypeDeserializer typeDeser, Annotations contextAnnotations)
{
this(propDef.getFullName(), type, propDef.getWrapperName(), typeDeser,
contextAnnotations, propDef.getMetadata());
}
private CustomVProperty(BeanPropertyDefinition propDef,
Annotations ctxtAnn, JavaType type) {
super(propDef, ctxtAnn, type);
}
protected MyVirtualPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations,
JavaType declaredType) {
super(propDef, contextAnnotations, declaredType);
}
/**
* @param name Name of the logical property
* @param type Type of the property, used to find deserializer
* @param typeDeser Type deserializer to use for handling polymorphic type
* information, if one is needed
* @param contextAnnotations Contextual annotations (usually by class that
* declares creator [constructor, factory method] that includes
* this property)
* @param param Representation of property, constructor or factory
* method parameter; used for accessing annotations of the property
* @param index Index of this property within creator invocation
*
* @since 2.3
*/
public CreatorProperty(PropertyName name, JavaType type, PropertyName wrapperName,
TypeDeserializer typeDeser,
Annotations contextAnnotations, AnnotatedParameter param,
int index, Object injectableValueId,
PropertyMetadata metadata)
{
super(name, type, wrapperName, typeDeser, contextAnnotations, metadata);
_annotated = param;
_creatorIndex = index;
_injectableValueId = injectableValueId;
_fallbackSetter = null;
}
/**
*
* @param propDef property definition created by {@code by com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector}
* @param annotations contains only @JsonAppend at the moment
* @param type {@link VirtualProperty}[]
* @param virtualProperties {@link VirtualProperty}-ies to append
* @param valueResolver {@link ValueResolver} dynamic variables resolver
*
* @deprecated This constructor should not be invoked directly and should only be used within
* {@link #withConfig(MapperConfig, AnnotatedClass, BeanPropertyDefinition, JavaType)} call.
* It will be removed in future releases.
*/
@Deprecated
public VirtualPropertiesWriter(
BeanPropertyDefinition propDef,
Annotations annotations,
JavaType type,
VirtualProperty[] virtualProperties,
ValueResolver valueResolver
) {
this(propDef, annotations, type, virtualProperties, valueResolver, new VirtualPropertyFilter[0]);
}
/**
* Method for accessing collection of annotations the bean
* class has.
*/
public abstract Annotations getClassAnnotations();
public static Annotations emptyAnnotations() { return NO_ANNOTATIONS; }
public abstract Annotations asAnnotations();