class ScoredValue<V> extends Value<V> {

    private static final ScoredValue<Object> EMPTY = new ScoredValue<>(0, null);

    private final double score;

    /**
     * Serializable constructor.
     */
    protected ScoredValue() {
        super(null);
        this.score = 0;
    }

    private ScoredValue(double score, V value) {
        super(value);
        this.score = score;
    }

    /**
     * Creates a {@link Value} from a {@code key} and an {@link Optional}. The resulting value contains the value from the
     * {@link Optional} if a value is present. Value is empty if the {@link Optional} is empty.
     *
     * @param score the score.
     * @param optional the optional. May be empty but never {@code null}.
     * @return the {@link Value}.
     */
    public static <T extends V, V> Value<V> from(double score, Optional<T> optional) {

        LettuceAssert.notNull(optional, "Optional must not be null");

        if (optional.isPresent()) {
            return new ScoredValue<>(score, optional.get());
        }

        return empty();
    }

    /**
     * Creates a {@link Value} from a {@code score} and {@code value}. The resulting value contains the value if the
     * {@code value} is not null.
     *
     * @param score the score.
     * @param value the value. May be {@code null}.
     * @return the {@link Value}.
     */
    public static <T extends V, V> Value<V> fromNullable(double score, T value) {

        if (value == null) {
            return empty();
        }

        return new ScoredValue<>(score, value);
    }

    /**
     * Returns an empty {@code ScoredValue} instance. No value is present for this instance.
     *
     * @return the {@link ScoredValue}
     */
    public static <V> ScoredValue<V> empty() {
        return (ScoredValue<V>) EMPTY;
    }

    /**
     * Creates a {@link ScoredValue} from a {@code key} and {@code value}. The resulting value contains the value.
     *
     * @param score the score.
     * @param value the value. Must not be {@code null}.
     * @return the {@link ScoredValue}.
     */
    public static <T extends V, V> ScoredValue<V> just(double score, T value) {

        LettuceAssert.notNull(value, "Value must not be null");

        return new ScoredValue<>(score, value);
    }

    public double getScore() {
        return score;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (!(o instanceof ScoredValue))
            return false;
        if (!super.equals(o))
            return false;

        ScoredValue<?> that = (ScoredValue<?>) o;

        return Double.compare(that.score, score) == 0;
    }

    @Override
    public int hashCode() {

        long temp = Double.doubleToLongBits(score);
        int result = (int) (temp ^ (temp >>> 32));
        result = 31 * result + (hasValue() ? getValue().hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return hasValue() ? String.format("ScoredValue[%f, %s]", score, getValue())
                : String.format("ScoredValue[%f].empty", score);
    }

    /**
     * Returns a {@link ScoredValue} consisting of the results of applying the given function to the value of this element.
     * Mapping is performed only if a {@link #hasValue() value is present}.
     *
     * @param <R> element type of the new {@link ScoredValue}.
     * @param mapper a stateless function to apply to each element.
     * @return the new {@link ScoredValue}.
     */
    @SuppressWarnings("unchecked")
    public <R> ScoredValue<R> map(Function<? super V, ? extends R> mapper) {<FILL_FUNCTION_BODY>}

    /**
     * Returns a {@link ScoredValue} consisting of the results of applying the given function to the score of this element.
     * Mapping is performed only if a {@link #hasValue() value is present}.
     *
     * @param mapper a stateless function to apply to each element.
     * @return the new {@link ScoredValue} .
     */
    @SuppressWarnings("unchecked")
    public ScoredValue<V> mapScore(Function<? super Number, ? extends Number> mapper) {

        LettuceAssert.notNull(mapper, "Mapper function must not be null");

        if (hasValue()) {
            return new ScoredValue<>(mapper.apply(score).doubleValue(), getValue());
        }

        return this;
    }

}


        LettuceAssert.notNull(mapper, "Mapper function must not be null");

        if (hasValue()) {
            return new ScoredValue<>(score, mapper.apply(getValue()));
        }

        return (ScoredValue<R>) this;
    
<methods>public static Value<V> empty() ,public boolean equals(java.lang.Object) ,public static Value<V> from(Optional<T>) ,public static Value<V> fromNullable(T) ,public V getValue() ,public V getValueOrElse(V) ,public V getValueOrElseGet(Supplier<V>) ,public V getValueOrElseThrow(Supplier<? extends X>) throws X,public boolean hasValue() ,public int hashCode() ,public void ifEmpty(java.lang.Runnable) ,public void ifHasValue(Consumer<? super V>) ,public void ifHasValueOrElse(Consumer<? super V>, java.lang.Runnable) ,public boolean isEmpty() ,public static Value<V> just(T) ,public Value<R> map(Function<? super V,? extends R>) ,public Optional<V> optional() ,public Stream<V> stream() ,public java.lang.String toString() <variables>private static final Value<java.lang.Object> EMPTY,private final non-sealed V value