RemovalNotification
Date: 2016-05-24

com.google.common.cache

## Class RemovalNotification<K,V>

- java.lang.Object
- - com.google.common.cache.RemovalNotification<K,V>

- All Implemented Interfaces:
    java.util.Map.Entry<K,V>

      @GwtCompatible
      public final class RemovalNotification<K,V>
      extends java.lang.Object
      implements java.util.Map.Entry<K,V>

  A notification of the removal of a single entry. The key and/or value may be null if they were already garbage collected.

  Like other `Map.Entry` instances associated with `CacheBuilder`, this class holds strong references to the key and value, regardless of the type of references the cache may be using.

  Since:
    10.0

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <K,V> RemovalNotification<K,V>` | `create(K key, V value, RemovalCause cause)` Creates a new `RemovalNotification` for the given `key`/`value` pair, with the given `cause` for the removal.
    `boolean` | `equals(java.lang.Object object)`
    `RemovalCause` | `getCause()` Returns the cause for which the entry was removed.
    `K` | `getKey()`
    `V` | `getValue()`
    `int` | `hashCode()`
    `V` | `setValue(V value)`
    `java.lang.String` | `toString()` Returns a string representation of the form `{key}={value}`.
    `boolean` | `wasEvicted()` Returns `true` if there was an automatic removal due to eviction (the cause is neither `RemovalCause.EXPLICIT` nor `RemovalCause.REPLACED`).

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Method Detail

    - #### create

          public static <K,V> RemovalNotification<K,V> create(@Nullable
                                              K key,
                                              @Nullable
                                              V value,
                                              RemovalCause cause)

      Creates a new `RemovalNotification` for the given `key`/`value` pair, with the given `cause` for the removal. The `key` and/or `value` may be `null` if they were already garbage collected.
      Since:
        19.0

    - #### getCause

          public RemovalCause getCause()

      Returns the cause for which the entry was removed.

    - #### wasEvicted

          public boolean wasEvicted()

      Returns `true` if there was an automatic removal due to eviction (the cause is neither `RemovalCause.EXPLICIT` nor `RemovalCause.REPLACED`).

    - #### getKey

          @Nullable
          public K getKey()

      Specified by:
        `getKey` in interface `java.util.Map.Entry<K,V>`

    - #### getValue

          @Nullable
          public V getValue()

      Specified by:
        `getValue` in interface `java.util.Map.Entry<K,V>`

    - #### setValue

          public final V setValue(V value)

      Specified by:
        `setValue` in interface `java.util.Map.Entry<K,V>`

    - #### equals

          public boolean equals(@Nullable
                       java.lang.Object object)

      Specified by:
        `equals` in interface `java.util.Map.Entry<K,V>`
      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in interface `java.util.Map.Entry<K,V>`
      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### toString

          public java.lang.String toString()

      Returns a string representation of the form `{key}={value}`.
      Overrides:
        `toString` in class `java.lang.Object`