Search in sources :

Example 1 with NoArgCollectionSerializer

use of io.paperdb.serializer.NoArgCollectionSerializer in project Paper by pilgr.

the class DbStoragePlainFile method createKryoInstance.

private Kryo createKryoInstance() {
    Kryo kryo = new Kryo();
    kryo.register(PaperTable.class);
    kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
    kryo.setReferences(false);
    // Serialize Arrays$ArrayList
    //noinspection ArraysAsListWithZeroOrOneArgument
    kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);
    SynchronizedCollectionsSerializer.registerSerializers(kryo);
    // Serialize inner AbstractList$SubAbstractListRandomAccess
    kryo.addDefaultSerializer(new ArrayList<>().subList(0, 0).getClass(), new NoArgCollectionSerializer());
    // Serialize AbstractList$SubAbstractList
    kryo.addDefaultSerializer(new LinkedList<>().subList(0, 0).getClass(), new NoArgCollectionSerializer());
    // To keep backward compatibility don't change the order of serializers above
    // UUID support
    kryo.register(UUID.class, new UUIDSerializer());
    for (Class<?> clazz : mCustomSerializers.keySet()) kryo.register(clazz, mCustomSerializers.get(clazz));
    kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
    return kryo;
}
Also used : NoArgCollectionSerializer(io.paperdb.serializer.NoArgCollectionSerializer) StdInstantiatorStrategy(org.objenesis.strategy.StdInstantiatorStrategy) UUIDSerializer(de.javakaffee.kryoserializers.UUIDSerializer) ArraysAsListSerializer(de.javakaffee.kryoserializers.ArraysAsListSerializer) Kryo(com.esotericsoftware.kryo.Kryo)

Aggregations

Kryo (com.esotericsoftware.kryo.Kryo)1 ArraysAsListSerializer (de.javakaffee.kryoserializers.ArraysAsListSerializer)1 UUIDSerializer (de.javakaffee.kryoserializers.UUIDSerializer)1 NoArgCollectionSerializer (io.paperdb.serializer.NoArgCollectionSerializer)1 StdInstantiatorStrategy (org.objenesis.strategy.StdInstantiatorStrategy)1