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;
|
2021-02-04 00:48:49 +01:00
|
|
|
import it.cavallium.dbengine.database.LLDictionary;
|
|
|
|
import it.cavallium.dbengine.database.serialization.Serializer;
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
|
|
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) {
|
2022-03-20 14:33:27 +01:00
|
|
|
return new DatabaseMapSingle<>(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() {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|