Interface EntryView.ReadEntryView<K,V>
-
- All Superinterfaces:
MetaParam.Lookup
- All Known Subinterfaces:
EntryView.ReadWriteEntryView<K,V>
- Enclosing class:
- EntryView
@Experimental public static interface EntryView.ReadEntryView<K,V> extends MetaParam.Lookup
Expose read-only information about a cache entry potentially associated with a key in the functional map. Typically, if the key is associated with a cache entry, that information will include value and optionalMetaParam
information.It exposes both
get()
andfind()
methods for convenience. If the caller knows for sure that the value will be present,get()
offers the convenience of retrieving the value directly without having to get anOptional
first. As a result of this,get()
throwsNoSuchElementException
if there's no value associated with the entry. If the caller is unsure of whether the value is present,find()
should be used. This approach avoids the user having to do null checks.- Since:
- 8.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Optional<V>
find()
Optional value.V
get()
Returns a non-null value if the key has a value associated with it or throwsNoSuchElementException
if no value is associated with the entry.K
key()
Key of the read-only entry view.default Optional<V>
peek()
The same asfind()
but does not update any hit/miss statistics.-
Methods inherited from interface org.infinispan.functional.MetaParam.Lookup
findMetaParam
-
-
-
-
Method Detail
-
key
K key()
Key of the read-only entry view. Guaranteed to return a non-null value. The instance of the key must not be mutated.
-
get
V get() throws NoSuchElementException
Returns a non-null value if the key has a value associated with it or throwsNoSuchElementException
if no value is associated with the entry.The value instance is read-only and must not be mutated. If the function accessing this value is about to update the entry, it has to create a defensive copy (or completely new instance) and store it using
EntryView.WriteEntryView.set(Object, MetaParam.Writable[])
.- Throws:
NoSuchElementException
- if no value is associated with the key.
-
find
Optional<V> find()
Optional value. It'll return a non-empty value when the value is present, and empty when the value is not present.The value instance is read-only and must not be mutated. If the function accessing this value is about to update the entry, it has to create a defensive copy (or completely new instance) and store it using
EntryView.WriteEntryView.set(Object, MetaParam.Writable[])
.
-
-