org.apache.ignite.internal.processors.cache

## Class CacheEvictableEntryImpl<K,V>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.CacheEvictableEntryImpl<K,V>

All Implemented Interfaces:
  javax.cache.Cache.Entry<K,V>, EvictableEntry<K,V>

    public class CacheEvictableEntryImpl<K,V>
    extends Object
    implements EvictableEntry<K,V>

Entry wrapper that never obscures obsolete entries from user.

### Field Summary

Fields
`protected GridCacheEntryEx` `cached` Cached entry.

### Constructor Summary

Constructors
`protected` `CacheEvictableEntryImpl(GridCacheEntryEx cached)`

### Method Summary

Methods
`<T> T` `addMeta(T val)` Adds a new metadata.
`boolean` `equals(Object obj)`
`boolean` `evict()` Evicts entry associated with given key from cache.
`K` `getKey()`
`V` `getValue()`
`int` `hashCode()`
`boolean` `isCached()` Checks whether entry is currently present in cache or not.
`<T> T` `meta()` Gets metadata added by eviction policy.
`V` `peek()`
`<T> T` `putMetaIfAbsent(T val)` Adds given metadata value only if it was absent.
`<T> T` `removeMeta()` Removes metadata by name.
`<T> boolean` `removeMeta(T val)` Removes metadata only if its current value is equal to `val` passed in.
`<T> boolean` `replaceMeta(T curVal, T newVal)` Replaces given metadata with new `newVal` value only if its current value is equal to `curVal`.
`int` `size()` Returns entry size in bytes.
`String` `toString()`
`<T> T` `unwrap(Class<T> clazz)`

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

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

### Field Detail

#### cached

    @GridToStringInclude
    protected GridCacheEntryEx cached

Cached entry.

### Constructor Detail

#### CacheEvictableEntryImpl

    protected CacheEvictableEntryImpl(GridCacheEntryEx cached)

Parameters:
  `cached` - Cached entry.

### Method Detail

#### getKey

    public K getKey()
             throws IllegalStateException

Specified by:
  `getKey` in interface `javax.cache.Cache.Entry<K,V>`
Throws:
  `IllegalStateException`

#### isCached

    public boolean isCached()

Checks whether entry is currently present in cache or not. If entry is not in cache (e.g. has been removed) `false` is returned. In this case all operations on this entry will cause creation of a new entry in cache.

Specified by:
  `isCached` in interface `EvictableEntry<K,V>`
Returns:
  `True` if entry is in cache, `false` otherwise.

#### evict

    public boolean evict()

Evicts entry associated with given key from cache. Note, that entry will be evicted only if it's not used (not participating in any locks or transactions).

Specified by:
  `evict` in interface `EvictableEntry<K,V>`
Returns:
  `True` if entry could be evicted, `false` otherwise.

#### peek

    @Nullable
    public V peek()

Returns:
  Peeks value.

#### size

    public int size()

Returns entry size in bytes.

Specified by:
  `size` in interface `EvictableEntry<K,V>`
Returns:
  entry size in bytes.

#### getValue

    public V getValue()

Specified by:
  `getValue` in interface `javax.cache.Cache.Entry<K,V>`

#### addMeta

    @Nullable
    public <T> T addMeta(T val)

Adds a new metadata.

Specified by:
  `addMeta` in interface `EvictableEntry<K,V>`
Parameters:
  `val` - Metadata value.
Returns:
  Metadata previously added, or `null` if there was none.

#### meta

    @Nullable
    public <T> T meta()

Gets metadata added by eviction policy.

Specified by:
  `meta` in interface `EvictableEntry<K,V>`
Returns:
  Metadata value or `null`.

#### removeMeta

    @Nullable
    public <T> T removeMeta()

Removes metadata by name.

Specified by:
  `removeMeta` in interface `EvictableEntry<K,V>`
Returns:
  Value of removed metadata or `null`.

#### removeMeta

    public <T> boolean removeMeta(T val)

Removes metadata only if its current value is equal to `val` passed in.

Specified by:
  `removeMeta` in interface `EvictableEntry<K,V>`
Parameters:
  `val` - Value to compare.
Returns:
  `True` if value was removed, `false` otherwise.

#### putMetaIfAbsent

    @Nullable
    public <T> T putMetaIfAbsent(T val)

Adds given metadata value only if it was absent.

Specified by:
  `putMetaIfAbsent` in interface `EvictableEntry<K,V>`
Parameters:
  `val` - Value to add if it's not attached already.
Returns:
  `null` if new value was put, or current value if put didn't happen.

#### replaceMeta

    public <T> boolean replaceMeta(T curVal,
                          T newVal)

Replaces given metadata with new `newVal` value only if its current value is equal to `curVal`. Otherwise, it is no-op.

Specified by:
  `replaceMeta` in interface `EvictableEntry<K,V>`
Parameters:
  `curVal` - Current value to check.
  `newVal` - New value.
Returns:
  `true` if replacement occurred, `false` otherwise.

#### unwrap

    public <T> T unwrap(Class<T> clazz)

Specified by:
  `unwrap` in interface `javax.cache.Cache.Entry<K,V>`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### equals

    public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.9.0
Release Date | : March 2 2017