Update hitkey
This commit is contained in:
parent
62c2dabd8c
commit
0e9b45ebf9
|
@ -1,8 +1,10 @@
|
||||||
package it.cavallium.dbengine.client;
|
package it.cavallium.dbengine.client;
|
||||||
|
|
||||||
|
import it.cavallium.dbengine.database.collections.DatabaseEmpty.Nothing;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
public record HitKey<T>(T key, float score) implements Comparable<HitKey<T>> {
|
public record HitKey<T>(T key, float score) implements Comparable<HitKey<T>> {
|
||||||
|
@ -11,6 +13,14 @@ public record HitKey<T>(T key, float score) implements Comparable<HitKey<T>> {
|
||||||
return valueGetter.apply(key).map(value -> new HitEntry<>(key, value, score));
|
return valueGetter.apply(key).map(value -> new HitEntry<>(key, value, score));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public <U> HitEntry<T, U> withNullValue() {
|
||||||
|
return new HitEntry<>(key, null, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HitEntry<T, Nothing> withNothingValue() {
|
||||||
|
return new HitEntry<>(key, Nothing.INSTANCE, score);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(@NotNull HitKey<T> o) {
|
public int compareTo(@NotNull HitKey<T> o) {
|
||||||
return Float.compare(o.score, this.score);
|
return Float.compare(o.score, this.score);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user