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

org.zapodot.jackson.java8.JavaOptionalSerializers Maven / Gradle / Ivy

Go to download

Jackson Databind module for serializing and deserializing Java 8 java.util.Option objects. This tool is forked from original source created by @realjenius

There is a newer version: 2.6.1
Show newest version
package org.zapodot.jackson.java8;

import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.ser.Serializers;

import java.util.Optional;

/**
 * @author R.J. Lorimer [[email protected]]
 */
public class JavaOptionalSerializers extends Serializers.Base {
    @Override
    public JsonSerializer findSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc) {
        Class raw = type.getRawClass();
        if(Optional.class.isAssignableFrom(raw)) {
            return new JavaOptionalSerializer(type);
        }
        return super.findSerializer(config, type, beanDesc);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy