Package io.lettuce.core
Class KeyValue<K,V>
- java.lang.Object
-
- io.lettuce.core.Value<V>
-
- io.lettuce.core.KeyValue<K,V>
-
- Type Parameters:
K
- Key type.V
- Value type.
- All Implemented Interfaces:
Serializable
public class KeyValue<K,V> extends Value<V>
A key-value container extension toValue
. AKeyValue
requires always a non-null key on construction.- Author:
- Will Glozer, Mark Paluch
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
KeyValue()
Serializable constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K,V>
KeyValue<K,V>empty(K key)
Returns an emptyKeyValue
instance with thekey
set.boolean
equals(Object o)
static <K,T extends V,V>
KeyValue<K,V>from(K key, Optional<T> optional)
static <K,T extends V,V>
KeyValue<K,V>fromNullable(K key, T value)
K
getKey()
int
hashCode()
static <K,T extends V,V>
KeyValue<K,V>just(K key, T value)
<R> KeyValue<K,R>
map(Function<? super V,? extends R> mapper)
Returns aKeyValue
consisting of the results of applying the given function to the value of this element.String
toString()
-
Methods inherited from class io.lettuce.core.Value
empty, from, fromNullable, getValue, getValueOrElse, getValueOrElseGet, getValueOrElseThrow, hasValue, ifEmpty, ifHasValue, ifHasValueOrElse, isEmpty, just, optional, stream
-
-
-
-
Method Detail
-
from
public static <K,T extends V,V> KeyValue<K,V> from(K key, Optional<T> optional)
Creates aKeyValue
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:
key
- the key, must not benull
.optional
- the optional. May be empty but nevernull
.- Returns:
- the
KeyValue
-
fromNullable
public static <K,T extends V,V> KeyValue<K,V> fromNullable(K key, T value)
Creates aKeyValue
from akey
andvalue
. The resulting value contains the value if thevalue
is not null.- Parameters:
key
- the key, must not benull
.value
- the value. May benull
.- Returns:
- the
KeyValue
-
empty
public static <K,V> KeyValue<K,V> empty(K key)
Returns an emptyKeyValue
instance with thekey
set. No value is present for this instance.- Parameters:
key
- the key, must not benull
.- Returns:
- the
KeyValue
-
just
public static <K,T extends V,V> KeyValue<K,V> just(K key, T value)
- Parameters:
key
- the key. Must not benull
.value
- the value. Must not benull
.- Returns:
- the
KeyValue
-
getKey
public K getKey()
- Returns:
- the key
-
-