org.apache.ignite.internal.processors.datastructures

## Class GridCacheAtomicReferenceImpl<T>

- java.lang.Object
- - org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl<T>

All Implemented Interfaces:
  Closeable, Externalizable, Serializable, AutoCloseable, IgniteAtomicReference<T>, GridCacheAtomicReferenceEx<T>, GridCacheRemovable

    public final class GridCacheAtomicReferenceImpl<T>
    extends Object
    implements GridCacheAtomicReferenceEx<T>, Externalizable

Cache atomic reference implementation.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`GridCacheAtomicReferenceImpl()` Empty constructor required by `Externalizable`.
`GridCacheAtomicReferenceImpl(String name, GridCacheInternalKey key, IgniteInternalCache<GridCacheInternalKey,GridCacheAtomicReferenceValue<T>> atomicView, GridCacheContext ctx)` Default constructor.

### Method Summary

Methods
`void` `close()` Removes this atomic reference.
`boolean` `compareAndSet(T expVal, T newVal)` Conditionally sets the new value.
`T` `get()` Gets current value of an atomic reference.
`GridCacheInternalKey` `key()` Get current atomic reference key.
`String` `name()` Name of atomic reference.
`void` `onInvalid(Exception err)`
`boolean` `onRemoved()` Set status of data structure as removed.
`void` `readExternal(ObjectInput in)`
`boolean` `removed()` Gets status of atomic.
`void` `set(T val)` Unconditionally sets the value.
`String` `toString()`
`void` `writeExternal(ObjectOutput out)`

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

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

### Constructor Detail

#### GridCacheAtomicReferenceImpl

    public GridCacheAtomicReferenceImpl()

Empty constructor required by `Externalizable`.

#### GridCacheAtomicReferenceImpl

    public GridCacheAtomicReferenceImpl(String name,
                                GridCacheInternalKey key,
                                IgniteInternalCache<GridCacheInternalKey,GridCacheAtomicReferenceValue<T>> atomicView,
                                GridCacheContext ctx)

Default constructor.

Parameters:
  `name` - Atomic reference name.
  `key` - Atomic reference key.
  `atomicView` - Atomic projection.
  `ctx` - Cache context.

### Method Detail

#### name

    public String name()

Name of atomic reference.

Specified by:
  `name` in interface `IgniteAtomicReference<T>`
Returns:
  Name of an atomic reference.

#### get

    public T get()

Gets current value of an atomic reference.

Specified by:
  `get` in interface `IgniteAtomicReference<T>`
Returns:
  current value of an atomic reference.

#### set

    public void set(T val)

Unconditionally sets the value.

Specified by:
  `set` in interface `IgniteAtomicReference<T>`
Parameters:
  `val` - Value.

#### compareAndSet

    public boolean compareAndSet(T expVal,
                        T newVal)

Conditionally sets the new value. That will be set if `expVal` is equal to current value respectively.

Specified by:
  `compareAndSet` in interface `IgniteAtomicReference<T>`
Parameters:
  `expVal` - Expected value.
  `newVal` - New value.
Returns:
  Result of operation execution. If `true` than value have been updated.

#### onRemoved

    public boolean onRemoved()

Set status of data structure as removed.

Specified by:
  `onRemoved` in interface `GridCacheRemovable`
Returns:
  Current status.

#### onInvalid

    public void onInvalid(@Nullable
                 Exception err)

Specified by:
  `onInvalid` in interface `GridCacheRemovable`
Parameters:
  `err` - Error which cause data structure to become invalid.

#### key

    public GridCacheInternalKey key()

Get current atomic reference key.

Specified by:
  `key` in interface `GridCacheAtomicReferenceEx<T>`
Returns:
  Atomic reference key.

#### removed

    public boolean removed()

Gets status of atomic.

Specified by:
  `removed` in interface `IgniteAtomicReference<T>`
Returns:
  `true` if an atomic reference was removed from cache, `false` otherwise.

#### close

    public void close()

Removes this atomic reference.

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `IgniteAtomicReference<T>`

#### writeExternal

    public void writeExternal(ObjectOutput out)
                       throws IOException

Specified by:
  `writeExternal` in interface `Externalizable`
Throws:
  `IOException`

#### readExternal

    public void readExternal(ObjectInput in)
                      throws IOException,
                             ClassNotFoundException

Specified by:
  `readExternal` in interface `Externalizable`
Throws:
  `IOException`
  `ClassNotFoundException`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.1.0-incubating
Release Date | : May 20 2015