All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dorkbox.util.storage.StorageBuilder Maven / Gradle / Ivy

package dorkbox.util.storage;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.KryoException;
import com.esotericsoftware.kryo.Serializer;

public
interface StorageBuilder {
    /**
     * Builds the storage using the specified configuration
     */
    Storage build();

    /**
     * Registers the class using the lowest, next available integer ID and the {@link Kryo#getDefaultSerializer(Class) default serializer}.
     * If the class is already registered, the existing entry is updated with the new serializer.
     * 

* Registering a primitive also affects the corresponding primitive wrapper. *

* Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when using this * method. The order must be the same at deserialization as it was for serialization. */ StorageBuilder register(Class clazz); /** * Registers the class using the specified ID. If the ID is already in use by the same type, the old entry is overwritten. If the ID * is already in use by a different type, a {@link KryoException} is thrown. *

* Registering a primitive also affects the corresponding primitive wrapper. *

* IDs must be the same at deserialization as they were for serialization. * * @param id Must be >= 0. Smaller IDs are serialized more efficiently. IDs 0-8 are used by default for primitive types and String, but * these IDs can be repurposed. */ StorageBuilder register(Class clazz, int id); /** * Registers the class using the lowest, next available integer ID and the specified serializer. If the class is already registered, * the existing entry is updated with the new serializer. *

* Registering a primitive also affects the corresponding primitive wrapper. *

* Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when using this * method. The order must be the same at deserialization as it was for serialization. */ StorageBuilder register(Class clazz, Serializer serializer); /** * Registers the class using the specified ID and serializer. If the ID is already in use by the same type, the old entry is * overwritten. If the ID is already in use by a different type, a {@link KryoException} is thrown. *

* Registering a primitive also affects the corresponding primitive wrapper. *

* IDs must be the same at deserialization as they were for serialization. * * @param id Must be >= 0. Smaller IDs are serialized more efficiently. IDs 0-8 are used by default for primitive types and String, but * these IDs can be repurposed. */ StorageBuilder register(Class clazz, Serializer serializer, int id); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy