CavalliumDBEngine/src/main/java/it/cavallium/dbengine/database/collections/DatabaseInt.java

31 lines
828 B
Java
Raw Normal View History

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
public class DatabaseInt implements LLKeyValueDatabaseStructure {
2020-12-07 22:15:18 +01:00
private final LLSingleton singleton;
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();
}
}