Module 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 to Value.
Author:
Will Glozer, Mark Paluch
See Also:
Serialized Form
  • Constructor Details

    • ScoredValue

      protected ScoredValue()
      Serializable constructor.
  • Method Details

    • from

      public static <T extends V,​ V> Value<V> from​(double score, Optional<T> optional)
      Creates a Value from a key and an Optional. The resulting value contains the value from the Optional if a value is present. Value is empty if the Optional is empty.
      Parameters:
      score - the score.
      optional - the optional. May be empty but never null.
      Returns:
      the Value.
    • fromNullable

      public static <T extends V,​ V> Value<V> fromNullable​(double score, T value)
      Creates a Value from a score and value. The resulting value contains the value if the value is not null.
      Parameters:
      score - the score.
      value - the value. May be null.
      Returns:
      the Value.
    • empty

      public static <V> ScoredValue<V> empty()
      Returns an empty ScoredValue 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)
      Creates a ScoredValue from a key and value. The resulting value contains the value.
      Parameters:
      score - the score.
      value - the value. Must not be null.
      Returns:
      the ScoredValue.
    • getScore

      public double getScore()
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Value<V>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Value<V>
    • toString

      public String toString()
      Overrides:
      toString in class Value<V>
    • map

      public <R> ScoredValue<R> map​(Function<? super V,​? extends R> mapper)
      Returns a ScoredValue consisting of the results of applying the given function to the value of this element. Mapping is performed only if a value is present.
      Overrides:
      map in class Value<V>
      Type Parameters:
      R - element type of the new ScoredValue.
      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 a ScoredValue consisting of the results of applying the given function to the score of this element. Mapping is performed only if a value is present.
      Parameters:
      mapper - a stateless function to apply to each element.
      Returns:
      the new ScoredValue .