2021-02-04 00:48:49 +01:00
|
|
|
package it.cavallium.dbengine.database.collections;
|
|
|
|
|
2021-09-17 16:56:28 +02:00
|
|
|
import io.net5.buffer.api.Buffer;
|
|
|
|
import io.net5.buffer.api.BufferAllocator;
|
2021-09-23 02:15:58 +02:00
|
|
|
import io.net5.buffer.api.CompositeBuffer;
|
2021-09-17 16:56:28 +02:00
|
|
|
import io.net5.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-02-04 00:48:49 +01:00
|
|
|
import it.cavallium.dbengine.database.serialization.Serializer;
|
2021-09-02 17:15:40 +02:00
|
|
|
import it.cavallium.dbengine.database.serialization.Serializer.DeserializationResult;
|
2021-02-04 00:48:49 +01:00
|
|
|
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 final DeserializationResult<Nothing> NOTHING_RESULT = new DeserializationResult<>(NOTHING, 0);
|
2021-02-04 00:48:49 +01:00
|
|
|
|
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<>() {
|
|
|
|
@Override
|
2021-09-22 18:33:28 +02:00
|
|
|
public @NotNull DeserializationResult<Nothing> deserialize(@Nullable Send<Buffer> serialized) {
|
2021-08-31 09:14:46 +02:00
|
|
|
try (serialized) {
|
2021-09-02 17:15:40 +02:00
|
|
|
return NOTHING_RESULT;
|
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-09-23 02:15:58 +02:00
|
|
|
public @NotNull Send<Buffer> serialize(@NotNull Nothing deserialized) {
|
|
|
|
return LLUtils.empty(bufferAllocator);
|
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-08-31 09:14:46 +02:00
|
|
|
public static DatabaseStageEntry<Nothing> create(LLDictionary dictionary, Send<Buffer> key) {
|
|
|
|
return new DatabaseSingle<>(dictionary, key, nothingSerializer(dictionary.getAllocator()));
|
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() {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|