org.apache.ignite.internal.processors.datastructures

## Class GridCacheAtomicReferenceImpl<T>

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

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

    public final class GridCacheAtomicReferenceImpl<T>
    extends AtomicDataStructureProxy<GridCacheAtomicReferenceValue<T>>
    implements GridCacheAtomicReferenceEx<T>, IgniteChangeGlobalStateSupport, Externalizable

Cache atomic reference implementation.

See Also:
  Serialized Form

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.datastructures.AtomicDataStructureProxy

`cacheView, ctx, key, log, name, rmvd`

### Constructor Summary

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

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()` Removes this atomic reference.
`boolean` `compareAndSet(T expVal, T newVal)` Conditionally sets the new value.
`T` `compareAndSetAndGet(T newVal, T expVal)` Compares current value with specified value for equality and, if they are equal, replaces current value.
`T` `get()` Gets current value of an atomic reference.
`String` `name()` Name of atomic reference.
`void` `readExternal(ObjectInput in)`
`void` `set(T val)` Unconditionally sets the value.
`String` `toString()`
`void` `writeExternal(ObjectOutput out)`

### Methods inherited from class org.apache.ignite.internal.processors.datastructures.AtomicDataStructureProxy

`checkRemoved, checkRemovedAfterFail, invalidateLocalState, key, needCheckNotRemoved, onActivate, onDeActivate, onRemoved, removed, restart, suspend`

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

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

### Methods inherited from interface org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceEx

`key`

### Methods inherited from interface org.apache.ignite.internal.processors.datastructures.GridCacheRemovable

`needCheckNotRemoved, onRemoved, restart, suspend`

### Methods inherited from interface org.apache.ignite.IgniteAtomicReference

`removed`

### Methods inherited from interface org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport

`onActivate, onDeActivate`

### Constructor Detail

#### GridCacheAtomicReferenceImpl

    public GridCacheAtomicReferenceImpl()

Empty constructor required by `Externalizable`.

#### GridCacheAtomicReferenceImpl

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

Default constructor.

Parameters:
  `name` - Atomic reference name.
  `key` - Atomic reference key.
  `atomicView` - Atomic projection.

### Method Detail

#### name

    public String name()

Name of atomic reference.

Specified by:
  `name` in interface `IgniteAtomicReference<T>`
Overrides:
  `name` in class `AtomicDataStructureProxy<GridCacheAtomicReferenceValue<T>>`
Returns:
  Datastructure name.

#### 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.

#### compareAndSetAndGet

    public T compareAndSetAndGet(T newVal,
                                 T expVal)

Compares current value with specified value for equality and, if they are equal, replaces current value.

Parameters:
  `newVal` - New value to set.
  `expVal` - Expected value.
Returns:
  Original value.

#### 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`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.9.0
Release Date | : October 15 2020