2021-01-30 22:14:48 +01:00
|
|
|
package it.cavallium.dbengine.database.collections;
|
2020-12-07 22:15:18 +01:00
|
|
|
|
|
|
|
import com.google.common.primitives.Ints;
|
|
|
|
import it.cavallium.dbengine.database.LLKeyValueDatabaseStructure;
|
|
|
|
import it.cavallium.dbengine.database.LLSingleton;
|
|
|
|
import it.cavallium.dbengine.database.LLSnapshot;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
2021-01-30 10:52:14 +01:00
|
|
|
import reactor.core.publisher.Mono;
|
2020-12-07 22:15:18 +01:00
|
|
|
|
2021-01-31 00:36:21 +01:00
|
|
|
public class DatabaseInt implements LLKeyValueDatabaseStructure {
|
2020-12-07 22:15:18 +01:00
|
|
|
|
|
|
|
private final LLSingleton singleton;
|
|
|
|
|
2021-01-31 00:36:21 +01:00
|
|
|
public DatabaseInt(LLSingleton singleton) {
|
2020-12-07 22:15:18 +01:00
|
|
|
this.singleton = singleton;
|
|
|
|
}
|
|
|
|
|
2021-01-30 10:52:14 +01:00
|
|
|
public Mono<Integer> get(@Nullable LLSnapshot snapshot) {
|
|
|
|
return singleton.get(snapshot).map(Ints::fromByteArray);
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|
|
|
|
|
2021-01-30 10:52:14 +01:00
|
|
|
public Mono<Void> set(int value) {
|
|
|
|
return singleton.set(Ints.toByteArray(value));
|
2020-12-07 22:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getDatabaseName() {
|
|
|
|
return singleton.getDatabaseName();
|
|
|
|
}
|
|
|
|
}
|