2021-02-04 00:48:49 +01:00
|
|
|
package it.cavallium.dbengine.database.collections;
|
|
|
|
|
2021-04-30 19:15:04 +02:00
|
|
|
import io.netty.buffer.ByteBuf;
|
2021-02-04 00:48:49 +01:00
|
|
|
import it.cavallium.dbengine.database.LLDictionary;
|
|
|
|
import it.cavallium.dbengine.database.serialization.Serializer;
|
2021-04-12 17:09:55 +02:00
|
|
|
import java.util.function.Function;
|
2021-02-04 00:48:49 +01:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2021-04-30 19:15:04 +02:00
|
|
|
import static io.netty.buffer.Unpooled.*;
|
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-04-30 19:15:04 +02:00
|
|
|
public static final Serializer<Nothing, ByteBuf> NOTHING_SERIALIZER = new Serializer<>() {
|
2021-02-04 00:48:49 +01:00
|
|
|
@Override
|
2021-04-30 19:15:04 +02:00
|
|
|
public @NotNull Nothing deserialize(@NotNull ByteBuf serialized) {
|
2021-02-04 00:48:49 +01:00
|
|
|
return NOTHING;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-04-30 19:15:04 +02:00
|
|
|
public @NotNull ByteBuf serialize(@NotNull Nothing deserialized) {
|
|
|
|
return EMPTY_BUFFER;
|
2021-02-04 00:48:49 +01:00
|
|
|
}
|
|
|
|
};
|
2021-04-12 17:09:55 +02:00
|
|
|
public static final Function<Nothing, Nothing> NOTHING_HASH_FUNCTION = nothing -> nothing;
|
|
|
|
private static final SubStageGetter<Nothing, DatabaseStageEntry<Nothing>> NOTHING_SUB_STAGE_GETTER
|
|
|
|
= new SubStageGetterSingle<>(NOTHING_SERIALIZER);
|
2021-02-04 00:48:49 +01:00
|
|
|
|
|
|
|
private DatabaseEmpty() {
|
|
|
|
}
|
|
|
|
|
2021-04-30 19:15:04 +02:00
|
|
|
public static DatabaseStageEntry<Nothing> create(LLDictionary dictionary, ByteBuf key) {
|
2021-02-04 00:48:49 +01:00
|
|
|
return new DatabaseSingle<>(dictionary, key, NOTHING_SERIALIZER);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static SubStageGetter<Nothing, DatabaseStageEntry<Nothing>> createSubStageGetter() {
|
|
|
|
return NOTHING_SUB_STAGE_GETTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
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() {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|