All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jn.easyjson.jackson.ext.EasyJsonJacksonAnnotationIntrospector Maven / Gradle / Ivy

The newest version!
package com.jn.easyjson.jackson.ext;

import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.jn.easyjson.jackson.serializer.NullSerializer;

public class EasyJsonJacksonAnnotationIntrospector extends JacksonAnnotationIntrospector {
    @Override
    public Object findNullSerializer(Annotated a) {
        JsonSerialize ann = _findAnnotation(a, JsonSerialize.class);
        if (ann != null) {
            @SuppressWarnings("rawtypes")
            Class serClass = ann.nullsUsing();
            if (serClass != JsonSerializer.None.class) {
                return serClass;
            }
        }else{
            return new NullSerializer();
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy