Module lettuce.core

Class GeoValue<V>

java.lang.Object
io.lettuce.core.Value<V>
io.lettuce.core.GeoValue<V>
Type Parameters:
V - Value type.
All Implemented Interfaces:
Serializable

public class GeoValue<V>
extends Value<V>
A Geo value extension to Value.
Since:
6.1
Author:
Mark Paluch
See Also:
Serialized Form
  • Constructor Details

    • GeoValue

      protected GeoValue()
      Serializable constructor.
  • Method Details

    • from

      public static <T extends V,​ V> Value<V> from​(GeoCoordinates coordinates, 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:
      coordinates - the score.
      optional - the optional. May be empty but never null.
      Returns:
      the Value.
    • fromNullable

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

      public static <T extends V,​ V> GeoValue<V> just​(double longitude, double latitude, T value)
      Creates a GeoValue from a key and value. The resulting value contains the value.
      Parameters:
      longitude - the longitude coordinate according to WGS84.
      latitude - the latitude coordinate according to WGS84.
      value - the value. Must not be null.
      Returns:
      the GeoValue
    • just

      public static <T extends V,​ V> GeoValue<V> just​(GeoCoordinates coordinates, T value)
      Creates a GeoValue from a key and value. The resulting value contains the value.
      Parameters:
      coordinates - the coordinates.
      value - the value. Must not be null.
      Returns:
      the GeoValue.
    • getCoordinates

      public GeoCoordinates getCoordinates()
    • getLongitude

      public double getLongitude()
      Returns:
      the longitude if this instance has a Value.hasValue().
      Throws:
      NoSuchElementException - if the value is not present.
    • getLatitude

      public double getLatitude()
      Returns:
      the latitude if this instance has a Value.hasValue().
      Throws:
      NoSuchElementException - if the value is not present.
    • 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> GeoValue<R> map​(Function<? super V,​? extends R> mapper)
      Returns a GeoValue 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 GeoValue.
      Parameters:
      mapper - a stateless function to apply to each element.
      Returns:
      the new GeoValue.
    • mapCoordinates

      public GeoValue<V> mapCoordinates​(Function<? super GeoCoordinates,​? extends GeoCoordinates> mapper)
      Returns a GeoValue consisting of the results of applying the given function to the GeoCoordinates 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 GeoValue.