2021-02-04 00:48:49 +01:00
|
|
|
package it.cavallium.dbengine.database.collections;
|
|
|
|
|
2022-03-16 13:47:56 +01:00
|
|
|
import io.netty5.buffer.api.Buffer;
|
|
|
|
import io.netty5.buffer.api.BufferAllocator;
|
|
|
|
import io.netty5.buffer.api.Drop;
|
|
|
|
import io.netty5.buffer.api.Send;
|
2021-02-04 00:48:49 +01:00
|
|
|
import it.cavallium.dbengine.database.LLDictionary;
|
2021-09-23 02:15:58 +02:00
|
|
|
import it.cavallium.dbengine.database.LLUtils;
|
2021-10-19 00:22:05 +02:00
|
|
|
import it.cavallium.dbengine.database.serialization.SerializationException;
|
2021-02-04 00:48:49 +01:00
|
|
|
import it.cavallium.dbengine.database.serialization.Serializer;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
2021-09-22 18:33:28 +02:00
|
|
|
import org.jetbrains.annotations.Nullable;
|
2021-02-04 00:48:49 +01:00
|
|
|
|
|
|
|
public class DatabaseEmpty {
|
|
|
|
|
2021-04-03 19:09:06 +02:00
|
|
|
@SuppressWarnings({"unused", "InstantiationOfUtilityClass"})
|
2021-02-04 00:48:49 +01:00
|
|
|
public static final Nothing NOTHING = new Nothing();
|
|
|
|
|
2021-09-02 17:15:40 +02:00
|
|
|
public static Serializer<Nothing> nothingSerializer(BufferAllocator bufferAllocator) {
|
2021-08-31 09:14:46 +02:00
|
|
|
return new Serializer<>() {
|
2021-10-19 00:22:05 +02:00
|
|
|
|
2021-08-31 09:14:46 +02:00
|
|
|
@Override
|
2021-10-19 00:22:05 +02:00
|
|
|
public @NotNull Nothing deserialize(@NotNull Buffer serialized) {
|
|
|
|
return NOTHING;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void serialize(@NotNull Nothing deserialized, Buffer output) {
|
|
|
|
|
2021-08-31 09:14:46 +02:00
|
|
|
}
|
2021-02-04 00:48:49 +01:00
|
|
|
|
2021-08-31 09:14:46 +02:00
|
|
|
@Override
|
2021-10-19 00:22:05 +02:00
|
|
|
public int getSerializedSizeHint() {
|
|
|
|
return 0;
|
2021-08-31 09:14:46 +02:00
|
|
|
}
|
|
|
|
};
|
2021-02-04 00:48:49 +01:00
|
|
|
}
|
|
|
|
|
2021-08-31 09:14:46 +02:00
|
|
|
private DatabaseEmpty() {
|
2021-02-04 00:48:49 +01:00
|
|
|
}
|
|
|
|
|
2021-11-08 16:33:41 +01:00
|
|
|
public static DatabaseStageEntry<Nothing> create(LLDictionary dictionary, Buffer key, Runnable onClose) {
|
2021-10-01 19:17:33 +02:00
|
|
|
return new DatabaseSingle<>(dictionary, key, nothingSerializer(dictionary.getAllocator()), onClose);
|
2021-02-04 00:48:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final class Nothing {
|
|
|
|
|
2021-02-06 15:53:10 +01:00
|
|
|
@SuppressWarnings("InstantiationOfUtilityClass")
|
|
|
|
public static Nothing INSTANCE = new Nothing();
|
|
|
|
|
2021-02-04 00:48:49 +01:00
|
|
|
private Nothing() {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|