org.zapodot.jackson.java8.JavaOptionalSerializers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-databind-java-optional Show documentation
Show all versions of jackson-databind-java-optional Show documentation
Jackson Databind module for serializing and deserializing Java 8 java.util.Option objects.
This tool is forked from original source created by @realjenius
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