Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.jsontype;
  
  
Helper class used in cases where we caller has to override source for type identifier, for example when serializing a value using a delegate or surrogate value, in which case type id is to be based on the original value, but serialization done using surrogate.

Since:
2.2
 
 public class TypeSerializerWrapper
     extends TypeSerializer
 {
    
Actual TypeSerializer to use
 
     protected final TypeSerializer _delegate;
 
     protected final Object _value;
     
     public TypeSerializerWrapper(TypeSerializer delegateObject value)
     {
          = delegate;
          = value;
     }
     
     /*
     /**********************************************************
     /* TypeSerializer implementation, metadata
     /**********************************************************
      */
     
     @Override
     public TypeSerializer forProperty(BeanProperty prop) {
         TypeSerializer d2 = .forProperty(prop);
         if (d2 == ) {
             return this;
         }
         return new TypeSerializerWrapper(d2);
     }
 
     @Override
     public As getTypeInclusion() {
         return .getTypeInclusion();
     }
 
     @Override
     public String getPropertyName() {
         return .getPropertyName();
     }
 
     @Override
     public TypeIdResolver getTypeIdResolver() {
         return .getTypeIdResolver();
     }
 
     /*
     /**********************************************************
     /* TypeSerializer implementation, actual write methods
     /**********************************************************
      */
     
     @Override
     public void writeTypePrefixForScalar(Object valueJsonGenerator jgen)
             throws IOExceptionJsonProcessingException {
         .writeTypePrefixForScalar(jgen);
     }
 
     @Override
     public void writeTypePrefixForObject(Object valueJsonGenerator jgen)
             throws IOExceptionJsonProcessingException {
         .writeTypePrefixForObject(jgen);
     }
 
     @Override
     public void writeTypePrefixForArray(Object valueJsonGenerator jgen)
             throws IOExceptionJsonProcessingException {
         .writeTypePrefixForArray(jgen);
     }
 
     @Override
     public void writeTypeSuffixForScalar(Object valueJsonGenerator jgen)
             throws IOExceptionJsonProcessingException {
         .writeTypeSuffixForScalar(jgen);
     }
 
     @Override
     public void writeTypeSuffixForObject(Object valueJsonGenerator jgen)
             throws IOExceptionJsonProcessingException {
         .writeTypeSuffixForObject(jgen);
     }
 
    @Override
    public void writeTypeSuffixForArray(Object valueJsonGenerator jgen)
            throws IOExceptionJsonProcessingException {
    }
    @Override
    public void writeCustomTypePrefixForScalar(Object value,
            JsonGenerator jgenString typeIdthrows IOExceptionJsonProcessingException {
        .writeCustomTypePrefixForScalar(jgentypeId);
    }
    @Override
    public void writeCustomTypePrefixForObject(Object value,
            JsonGenerator jgenString typeIdthrows IOExceptionJsonProcessingException {
        .writeCustomTypePrefixForObject(jgentypeId);
    }
    @Override
    public void writeCustomTypePrefixForArray(Object valueJsonGenerator jgen,
            String typeIdthrows IOExceptionJsonProcessingException {
        .writeCustomTypePrefixForArray(jgentypeId);
    }
    @Override
    public void writeCustomTypeSuffixForScalar(Object value,
            JsonGenerator jgenString typeIdthrows IOExceptionJsonProcessingException {
        .writeCustomTypeSuffixForScalar(jgentypeId);
    }
    @Override
    public void writeCustomTypeSuffixForObject(Object value,
            JsonGenerator jgenString typeIdthrows IOException,
            JsonProcessingException {
        .writeCustomTypeSuffixForObject(jgentypeId);
    }
    @Override
    public void writeCustomTypeSuffixForArray(Object valueJsonGenerator jgen,
            String typeIdthrows IOExceptionJsonProcessingException {
        .writeCustomTypeSuffixForArray(jgentypeId);
    }
New to GrepCode? Check out our FAQ X