Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.fasterxml.jackson.databind.ser;
 
 import java.util.Map;
 
Class similar to BeanPropertyWriter, but that will be used for serializing com.fasterxml.jackson.annotation.JsonAnyGetter annotated (Map) properties
public class AnyGetterWriter
    protected final BeanProperty _property;

    
Method (or field) that represents the "any getter"
    protected final AnnotatedMember _accessor;
    
    protected MapSerializer _serializer;
    
    public AnyGetterWriter(BeanProperty property,
            AnnotatedMember accessorMapSerializer serializer)
    {
         = accessor;
         = property;
         = serializer;
    }
    public void getAndSerialize(Object beanJsonGenerator jgenSerializerProvider provider)
        throws Exception
    {
        Object value = .getValue(bean);
        if (value == null) {
            return;
        }
        if (!(value instanceof Map<?,?>)) {
            throw new JsonMappingException("Value returned by 'any-getter' ("
                    +.getName()+"()) not java.util.Map but "+value.getClass().getName());
        }
        .serializeFields((Map<?,?>) valuejgenprovider);
    }

    

Since:
2.3
    public void getAndFilter(Object beanJsonGenerator jgenSerializerProvider provider,
            PropertyFilter filter)
        throws Exception
        {
            Object value = .getValue(bean);
            if (value == null) {
                return;
            }
            if (!(value instanceof Map<?,?>)) {
                throw new JsonMappingException("Value returned by 'any-getter' ("
                        +.getName()+"()) not java.util.Map but "+value.getClass().getName());
            }
            .serializeFilteredFields((Map<?,?>) valuejgenproviderfilter);
        }
    
    // Note: NOT part of ResolvableSerializer...
    public void resolve(SerializerProvider providerthrows JsonMappingException
    {
        // 05-Sep-2013, tatu: I _think_ this can be considered a primary property...
    }
New to GrepCode? Check out our FAQ X