Package io.lettuce.core
Class ScoredValue<V>
- java.lang.Object
-
- io.lettuce.core.Value<V>
-
- io.lettuce.core.ScoredValue<V>
-
- Type Parameters:
V
- Value type.
- All Implemented Interfaces:
Serializable
public class ScoredValue<V> extends Value<V>
A scored-value extension toValue
.- Author:
- Will Glozer, Mark Paluch
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ScoredValue()
Serializable constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <V> ScoredValue<V>
empty()
Returns an emptyScoredValue
instance.boolean
equals(Object o)
static <T extends V,V>
Value<V>from(double score, Optional<T> optional)
static <T extends V,V>
Value<V>fromNullable(double score, T value)
double
getScore()
int
hashCode()
static <T extends V,V>
ScoredValue<V>just(double score, T value)
<R> ScoredValue<R>
map(Function<? super V,? extends R> mapper)
Returns aScoredValue
consisting of the results of applying the given function to the value of this element.ScoredValue<V>
mapScore(Function<? super Number,? extends Number> mapper)
Returns aScoredValue
consisting of the results of applying the given function to the score of this element.String
toString()
-
Methods inherited from class io.lettuce.core.Value
from, fromNullable, getValue, getValueOrElse, getValueOrElseGet, getValueOrElseThrow, hasValue, ifEmpty, ifHasValue, ifHasValueOrElse, isEmpty, just, optional, stream
-
-
-
-
Method Detail
-
from
public static <T extends V,V> Value<V> from(double score, Optional<T> optional)
Creates aValue
from akey
and anOptional
. The resulting value contains the value from theOptional
if a value is present. Value is empty if theOptional
is empty.- Parameters:
score
- the score.optional
- the optional. May be empty but nevernull
.- Returns:
- the
Value
.
-
fromNullable
public static <T extends V,V> Value<V> fromNullable(double score, T value)
Creates aValue
from ascore
andvalue
. The resulting value contains the value if thevalue
is not null.- Parameters:
score
- the score.value
- the value. May benull
.- Returns:
- the
Value
.
-
empty
public static <V> ScoredValue<V> empty()
Returns an emptyScoredValue
instance. No value is present for this instance.- Returns:
- the
ScoredValue
-
just
public static <T extends V,V> ScoredValue<V> just(double score, T value)
- Parameters:
score
- the score.value
- the value. Must not benull
.- Returns:
- the
ScoredValue
.
-
getScore
public double getScore()
-
map
public <R> ScoredValue<R> map(Function<? super V,? extends R> mapper)
Returns aScoredValue
consisting of the results of applying the given function to the value of this element. Mapping is performed only if avalue is present
.- Overrides:
map
in classValue<V>
- Type Parameters:
R
- element type of the newScoredValue
.- Parameters:
mapper
- a stateless function to apply to each element.- Returns:
- the new
ScoredValue
.
-
mapScore
public ScoredValue<V> mapScore(Function<? super Number,? extends Number> mapper)
Returns aScoredValue
consisting of the results of applying the given function to the score of this element. Mapping is performed only if avalue is present
.- Parameters:
mapper
- a stateless function to apply to each element.- Returns:
- the new
ScoredValue
.
-
-