com.github.ddth.commons.serialization.KryoSerDeser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ddth-commons-core Show documentation
Show all versions of ddth-commons-core Show documentation
DDTH's Java Common Libraries and Utilities
package com.github.ddth.commons.serialization;
import com.github.ddth.commons.utils.SerializationUtils;
/**
* This implementation of {@link ISerDeser} use Kryo library for
* serializing/deserializing.
*
* @author Thanh Nguyen
* @since 0.5.0
*/
public class KryoSerDeser implements ISerDeser {
/**
* {@inheritDoc}
*/
@Override
public byte[] toBytes(Object obj) throws SerializationException {
return toBytes(obj, null);
}
/**
* {@inheritDoc}
*/
@Override
public byte[] toBytes(Object obj, ClassLoader classLoader) throws SerializationException {
return SerializationUtils.toByteArrayKryo(obj, classLoader);
}
/**
* {@inheritDoc}
*/
@Override
public T fromBytes(byte[] data, Class clazz) throws DeserializationException {
return fromBytes(data, clazz, null);
}
/**
* {@inheritDoc}
*/
@Override
public T fromBytes(byte[] data, Class clazz, ClassLoader classLoader)
throws DeserializationException {
return SerializationUtils.fromByteArrayKryo(data, clazz, classLoader);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy