org.ssf4j.jackson.JacksonSerialization Maven / Gradle / Ivy
package org.ssf4j.jackson;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.ssf4j.Serialization;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* Serialization facade that uses Jackson's JSON mapper.
*
* Jackson cannot serialize everything, but comes pretty close.
* @author robin
*
*/
public class JacksonSerialization implements Serialization {
protected ObjectMapper mapper;
public JacksonSerialization() {}
public JacksonSerialization(ObjectMapper mapper) {
this.mapper = mapper;
}
/**
* {@inheritDoc}
*/
@Override
public JacksonSerializer newSerializer(OutputStream out, Class type)
throws IOException {
return new JacksonSerializer(out, mapper);
}
/**
* {@inheritDoc}
*/
@Override
public JacksonDeserializer newDeserializer(InputStream in, Class type)
throws IOException {
return new JacksonDeserializer(in, mapper, type);
}
}