org.apache.ignite.internal.processors.datastructures

## Class GridCacheAtomicLongImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl

All Implemented Interfaces:
  Closeable, Externalizable, Serializable, AutoCloseable, IgniteAtomicLong, GridCacheAtomicLongEx, GridCacheRemovable

    public final class GridCacheAtomicLongImpl
    extends Object
    implements GridCacheAtomicLongEx, Externalizable

Cache atomic long implementation.

See Also:
  Serialized Form

### Constructor Summary

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

### Method Summary

Methods
`long` `addAndGet(long l)` Adds `l` and gets current value of atomic long.
`void` `close()` Removes this atomic long.
`boolean` `compareAndSet(long expVal, long newVal)` Atomically compares current value to the expected value, and if they are equal, sets current value to new value.
`long` `compareAndSetAndGet(long expVal, long newVal)`
`long` `decrementAndGet()` Decrements and gets current value of atomic long.
`long` `get()` Gets current value of atomic long.
`long` `getAndAdd(long l)` Gets current value of atomic long and adds `l`.
`long` `getAndDecrement()` Gets and decrements current value of atomic long.
`long` `getAndIncrement()` Gets and increments current value of atomic long.
`long` `getAndSet(long l)` Gets current value of atomic long and sets new value `l` of atomic long.
`long` `incrementAndGet()` Increments and gets current value of atomic long.
`GridCacheInternalKey` `key()` Get current atomic long key.
`String` `name()` Name of atomic long.
`void` `needCheckNotRemoved()`
`boolean` `onRemoved()` Set status of data structure as removed.
`void` `readExternal(ObjectInput in)`
`boolean` `removed()` Gets status of atomic.
`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

#### GridCacheAtomicLongImpl

    public GridCacheAtomicLongImpl()

Empty constructor required by `Externalizable`.

#### GridCacheAtomicLongImpl

    public GridCacheAtomicLongImpl(String name,
                           GridCacheInternalKey key,
                           IgniteInternalCache<GridCacheInternalKey,GridCacheAtomicLongValue> atomicView,
                           GridCacheContext ctx)

Default constructor.

Parameters:
  `name` - Atomic long name.
  `key` - Atomic long key.
  `atomicView` - Atomic projection.
  `ctx` - CacheContext.

### Method Detail

#### name

    public String name()

Name of atomic long.

Specified by:
  `name` in interface `IgniteAtomicLong`
Returns:
  Name of atomic long.

#### get

    public long get()

Gets current value of atomic long.

Specified by:
  `get` in interface `IgniteAtomicLong`
Returns:
  Current value of atomic long.

#### incrementAndGet

    public long incrementAndGet()

Increments and gets current value of atomic long.

Specified by:
  `incrementAndGet` in interface `IgniteAtomicLong`
Returns:
  Value.

#### getAndIncrement

    public long getAndIncrement()

Gets and increments current value of atomic long.

Specified by:
  `getAndIncrement` in interface `IgniteAtomicLong`
Returns:
  Value.

#### addAndGet

    public long addAndGet(long l)

Adds `l` and gets current value of atomic long.

Specified by:
  `addAndGet` in interface `IgniteAtomicLong`
Parameters:
  `l` - Number which will be added.
Returns:
  Value.

#### getAndAdd

    public long getAndAdd(long l)

Gets current value of atomic long and adds `l`.

Specified by:
  `getAndAdd` in interface `IgniteAtomicLong`
Parameters:
  `l` - Number which will be added.
Returns:
  Value.

#### decrementAndGet

    public long decrementAndGet()

Decrements and gets current value of atomic long.

Specified by:
  `decrementAndGet` in interface `IgniteAtomicLong`
Returns:
  Value.

#### getAndDecrement

    public long getAndDecrement()

Gets and decrements current value of atomic long.

Specified by:
  `getAndDecrement` in interface `IgniteAtomicLong`
Returns:
  Value.

#### getAndSet

    public long getAndSet(long l)

Gets current value of atomic long and sets new value `l` of atomic long.

Specified by:
  `getAndSet` in interface `IgniteAtomicLong`
Parameters:
  `l` - New value of atomic long.
Returns:
  Value.

#### compareAndSet

    public boolean compareAndSet(long expVal,
                        long newVal)

Atomically compares current value to the expected value, and if they are equal, sets current value to new value.

Specified by:
  `compareAndSet` in interface `IgniteAtomicLong`
Parameters:
  `expVal` - Expected atomic long's value.
  `newVal` - New atomic long's value to set if current value equal to expected value.
Returns:
  `True` if comparison succeeded, `false` otherwise.

#### compareAndSetAndGet

    public long compareAndSetAndGet(long expVal,
                           long newVal)

Parameters:
  `expVal` - Expected value.
  `newVal` - New value.
Returns:
  Old value.

#### onRemoved

    public boolean onRemoved()

Set status of data structure as removed.

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

#### needCheckNotRemoved

    public void needCheckNotRemoved()

Specified by:
  `needCheckNotRemoved` in interface `GridCacheRemovable`

#### key

    public GridCacheInternalKey key()

Get current atomic long key.

Specified by:
  `key` in interface `GridCacheAtomicLongEx`
Returns:
  Atomic long key.

#### removed

    public boolean removed()

Gets status of atomic.

Specified by:
  `removed` in interface `IgniteAtomicLong`
Returns:
  `true` if atomic was removed from cache, `false` in other case.

#### close

    public void close()

Removes this atomic long.

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `IgniteAtomicLong`

#### 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.8.0
Release Date | : December 5 2016