com.fasterxml.jackson.databind.util.Annotations Java Examples

The following examples show how to use com.fasterxml.jackson.databind.util.Annotations. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotatedClass.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #2
Source File: SettableBeanProperty.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #3
Source File: AnnotatedClassResolver.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #4
Source File: AnnotationCollector.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #5
Source File: BeanDeserializerBuilder.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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));
}
 
Example #6
Source File: FieldProperty.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #7
Source File: MethodProperty.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #8
Source File: SetterlessProperty.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public SetterlessProperty(BeanPropertyDefinition propDef, JavaType type,
        TypeDeserializer typeDeser, Annotations contextAnnotations, AnnotatedMethod method)
{
    super(propDef, type, typeDeser, contextAnnotations);
    _annotated = method;
    _getter = method.getAnnotated();
}
 
Example #9
Source File: VirtualPropertiesWriter.java    From log4j2-elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #10
Source File: VirtualBeanPropertyWriter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #11
Source File: VirtualBeanPropertyWriter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #12
Source File: VirtualBeanPropertyWriter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor used by most sub-types.
 */
protected VirtualBeanPropertyWriter(BeanPropertyDefinition propDef,
        Annotations contextAnnotations, JavaType declaredType)
{
    this(propDef, contextAnnotations, declaredType, null, null, null,
            propDef.findInclusion());
}
 
Example #13
Source File: AttributePropertyWriter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public static AttributePropertyWriter construct(String attrName,
        BeanPropertyDefinition propDef,
        Annotations contextAnnotations,
        JavaType declaredType)
{
    return new AttributePropertyWriter(attrName, propDef,
            contextAnnotations, declaredType);
}
 
Example #14
Source File: AttributePropertyWriter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #15
Source File: BeanProperty.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @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);
}
 
Example #16
Source File: BeanPropertyWriter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #17
Source File: JsonAppendTest.java    From jackson-modules-base with Apache License 2.0 4 votes vote down vote up
protected MyVirtualPropertyWriter(BeanPropertyDefinition propDef, Annotations contextAnnotations,
        JavaType declaredType) {
    super(propDef, contextAnnotations, declaredType);
}
 
Example #18
Source File: TestVirtualProperties.java    From jackson-modules-base with Apache License 2.0 4 votes vote down vote up
private CustomVProperty(BeanPropertyDefinition propDef,
        Annotations ctxtAnn, JavaType type) {
    super(propDef, ctxtAnn, type);
}
 
Example #19
Source File: SettableBeanProperty.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected SettableBeanProperty(BeanPropertyDefinition propDef,
        JavaType type, TypeDeserializer typeDeser, Annotations contextAnnotations)
{
    this(propDef.getFullName(), type, propDef.getWrapperName(), typeDeser,
            contextAnnotations, propDef.getMetadata());
}
 
Example #20
Source File: AnnotationCollector.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Annotations asAnnotations() {
    return new OneAnnotation(_type, _value);
}
 
Example #21
Source File: AnnotationCollector.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Annotations asAnnotations() {
    return NO_ANNOTATIONS;
}
 
Example #22
Source File: AnnotatedClass.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Annotations getAnnotations() {
    return _classAnnotations;
}
 
Example #23
Source File: BasicBeanDescription.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Annotations getClassAnnotations() {
    return _classInfo.getAnnotations();
}
 
Example #24
Source File: AttributePropertyWriter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected AttributePropertyWriter(String attrName, BeanPropertyDefinition propDef,
        Annotations contextAnnotations, JavaType declaredType) {
    this(attrName, propDef, contextAnnotations, declaredType, propDef.findInclusion());
}
 
Example #25
Source File: CreatorProperty.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * @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;
}
 
Example #26
Source File: VirtualPropertiesWriter.java    From log4j2-elasticsearch with Apache License 2.0 3 votes vote down vote up
/**
 *
 * @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]);
}
 
Example #27
Source File: BeanDescription.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Method for accessing collection of annotations the bean
 * class has.
 */
public abstract Annotations getClassAnnotations();
 
Example #28
Source File: AnnotationCollector.java    From lams with GNU General Public License v2.0 votes vote down vote up
public abstract Annotations asAnnotations(); 
Example #29
Source File: AnnotationCollector.java    From lams with GNU General Public License v2.0 votes vote down vote up
public static Annotations emptyAnnotations() { return NO_ANNOTATIONS; }