Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.ser.std;
  
  
Helper class needed to support flexible filtering of Map properties with generic JSON Filter functionality. Since java.util.Maps are not handled as a collection of properties by Jackson (unlike POJOs), bit more wrapping is required.
 
 public class MapProperty extends PropertyWriter
 {
     protected TypeSerializer _typeSerializer;
     
     protected Object _key_value;
 
 
     public MapProperty(TypeSerializer typeSer)
     {
          = typeSer;
     }
    
    
Initialization method that needs to be called before passing property to filter.
 
     public void reset(Object keyObject value,
             JsonSerializer<ObjectkeySerJsonSerializer<ObjectvalueSer)
     {
          = key;
          = value;
          = keySer;
          = valueSer;
     }
     
     @Override
     public String getName() {
         if ( instanceof String) {
             return (String;
         }
         return String.valueOf();
     }
 
     @Override
     public PropertyName getFullName() {
         return new PropertyName(getName());
     }
 
     @Override
     public void serializeAsField(Object pojoJsonGenerator jgen,
             SerializerProvider providerthrows IOException
     {
         .serialize(jgenprovider);
         if ( == null) {
             .serialize(jgenprovider);
         } else {
             .serializeWithType(jgenprovider);
         }
     }
 
     @Override
     public void serializeAsOmittedField(Object pojoJsonGenerator jgen,
             SerializerProvider providerthrows Exception
     {
         if (!jgen.canOmitFields()) {
             jgen.writeOmittedField(getName());
         }
     }
 
     @Override
     public void serializeAsElement(Object pojoJsonGenerator jgen,
             SerializerProvider providerthrows Exception
     {
         if ( == null) {
             .serialize(jgenprovider);
         } else {
             .serializeWithType(jgenprovider);
         }
     }
     
     @Override
     public void serializeAsPlaceholder(Object pojoJsonGenerator jgen,
             SerializerProvider providerthrows Exception
     {
         jgen.writeNull();
     }
 
     @Override
    public void depositSchemaProperty(JsonObjectFormatVisitor objectVisitor)
        throws JsonMappingException
    {
        // !!! TODO
    }
    @Override
    @Deprecated
    public void depositSchemaProperty(ObjectNode propertiesNode,
            SerializerProvider providerthrows JsonMappingException {
        // !!! TODO
    }
New to GrepCode? Check out our FAQ X