Interface EntryView.ReadEntryView<K,​V>

  • All Superinterfaces:
    MetaParam.Lookup
    All Known Subinterfaces:
    EntryView.ReadWriteEntryView<K,​V>, EntryViews.AccessLoggingReadWriteView<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 optional 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.

    Since:
    8.0
    • 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.
      • 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[]).

      • peek

        default Optional<V> peek()
        The same as find() but does not update any hit/miss statistics.
        Returns: