SerializationManager register() methods now support chaining methods
This commit is contained in:
parent
8ca60fce73
commit
7818077686
@ -15,14 +15,16 @@
|
|||||||
*/
|
*/
|
||||||
package dorkbox.util;
|
package dorkbox.util;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import com.esotericsoftware.kryo.Kryo;
|
import com.esotericsoftware.kryo.Kryo;
|
||||||
import com.esotericsoftware.kryo.Serializer;
|
import com.esotericsoftware.kryo.Serializer;
|
||||||
import com.esotericsoftware.kryo.io.Input;
|
import com.esotericsoftware.kryo.io.Input;
|
||||||
import com.esotericsoftware.kryo.io.Output;
|
import com.esotericsoftware.kryo.io.Output;
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
public
|
public
|
||||||
interface SerializationManager {
|
interface SerializationManager {
|
||||||
@ -38,7 +40,7 @@ interface SerializationManager {
|
|||||||
* order classes are registered is important when using this method. The
|
* order classes are registered is important when using this method. The
|
||||||
* order must be the same at deserialization as it was for serialization.
|
* order must be the same at deserialization as it was for serialization.
|
||||||
*/
|
*/
|
||||||
void register(Class<?> clazz);
|
SerializationManager register(Class<?> clazz);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the class using the lowest, next available integer ID and the
|
* Registers the class using the lowest, next available integer ID and the
|
||||||
@ -50,8 +52,7 @@ interface SerializationManager {
|
|||||||
* order classes are registered is important when using this method. The
|
* order classes are registered is important when using this method. The
|
||||||
* order must be the same at deserialization as it was for serialization.
|
* order must be the same at deserialization as it was for serialization.
|
||||||
*/
|
*/
|
||||||
void register(Class<?> clazz, Serializer<?> serializer);
|
SerializationManager register(Class<?> clazz, Serializer<?> serializer);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the class using the specified ID and serializer. If the ID is
|
* Registers the class using the specified ID and serializer. If the ID is
|
||||||
@ -65,7 +66,7 @@ interface SerializationManager {
|
|||||||
* 0-8 are used by default for primitive types and String, but
|
* 0-8 are used by default for primitive types and String, but
|
||||||
* these IDs can be repurposed.
|
* these IDs can be repurposed.
|
||||||
*/
|
*/
|
||||||
void register(Class<?> clazz, Serializer<?> serializer, int id);
|
SerializationManager register(Class<?> clazz, Serializer<?> serializer, int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits until a kryo is available to write, using CAS operations to prevent having to synchronize.
|
* Waits until a kryo is available to write, using CAS operations to prevent having to synchronize.
|
||||||
|
@ -36,20 +36,23 @@ class DefaultStorageSerializationManager implements SerializationManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public
|
public
|
||||||
void register(final Class<?> clazz) {
|
SerializationManager register(final Class<?> clazz) {
|
||||||
kryo.register(clazz);
|
kryo.register(clazz);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public
|
public
|
||||||
void register(final Class<?> clazz, final Serializer<?> serializer) {
|
SerializationManager register(final Class<?> clazz, final Serializer<?> serializer) {
|
||||||
kryo.register(clazz, serializer);
|
kryo.register(clazz, serializer);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public
|
public
|
||||||
void register(final Class<?> type, final Serializer<?> serializer, final int id) {
|
SerializationManager register(final Class<?> type, final Serializer<?> serializer, final int id) {
|
||||||
kryo.register(type, serializer, id);
|
kryo.register(type, serializer, id);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user