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 to
Value. A KeyValue requires always a non-null key on construction.- Author:
- Will Glozer, Mark Paluch
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Modifier Constructor Description protectedKeyValue()Serializable constructor. -
Method Summary
Modifier and Type Method Description static <K, V> KeyValue<K,V>empty(K key)Returns an emptyKeyValueinstance with thekeyset.booleanequals(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)KgetKey()inthashCode()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 aKeyValueconsisting of the results of applying the given function to the value of this element.StringtoString()Methods inherited from class io.lettuce.core.Value
empty, from, fromNullable, getValue, getValueOrElse, getValueOrElseGet, getValueOrElseThrow, hasValue, ifEmpty, ifHasValue, ifHasValueOrElse, isEmpty, just, optional, stream
-
Constructor Details
-
KeyValue
protected KeyValue()Serializable constructor.
-
-
Method Details
-
from
Creates aKeyValuefrom akeyand anOptional. The resulting value contains the value from theOptionalif a value is present. Value is empty if theOptionalis empty.- Parameters:
key- the key, must not benull.optional- the optional. May be empty but nevernull.- Returns:
- the
KeyValue
-
fromNullable
Creates aKeyValuefrom akeyandvalue. The resulting value contains the value if thevalueis not null.- Parameters:
key- the key, must not benull.value- the value. May benull.- Returns:
- the
KeyValue
-
empty
Returns an emptyKeyValueinstance with thekeyset. No value is present for this instance.- Parameters:
key- the key, must not benull.- Returns:
- the
KeyValue
-
just
- Parameters:
key- the key. Must not benull.value- the value. Must not benull.- Returns:
- the
KeyValue
-
equals
-
hashCode
public int hashCode() -
toString
-
getKey
- Returns:
- the key
-
map
Returns aKeyValueconsisting of the results of applying the given function to the value of this element. Mapping is performed only if avalue is present.
-