@Experimental public static interface EntryView.ReadEntryView<K,V> extends MetaParam.Lookup
MetaParam
information.
It exposes both get()
and find()
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 an Optional
first. As a result
of this, get()
throws NoSuchElementException
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.
Modifier and Type | Method and Description |
---|---|
Optional<V> |
find()
Optional value.
|
V |
get()
Returns a non-null value if the key has a value associated with it or
throws
NoSuchElementException if no value is associated with
the entry. |
K |
key()
Key of the read-only entry view.
|
default Optional<V> |
peek()
The same as
find() but does not update any hit/miss statistics. |
findMetaParam
K key()
V get() throws NoSuchElementException
NoSuchElementException
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[])
.
NoSuchElementException
- if no value is associated with the key.Optional<V> find()
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[])
.
Copyright © 2021 JBoss by Red Hat. All rights reserved.