com.hazelcast.concurrent.atomicreference
Class AtomicReferenceProxy<E>

java.lang.Object
  extended by com.hazelcast.spi.AbstractDistributedObject<AtomicReferenceService>
      extended by com.hazelcast.concurrent.atomicreference.AtomicReferenceProxy<E>
All Implemented Interfaces:
AsyncAtomicReference<E>, DistributedObject, IAtomicReference<E>

public class AtomicReferenceProxy<E>
extends AbstractDistributedObject<AtomicReferenceService>
implements AsyncAtomicReference<E>


Field Summary
 
Fields inherited from class com.hazelcast.spi.AbstractDistributedObject
PARTITIONING_STRATEGY
 
Constructor Summary
AtomicReferenceProxy(String name, NodeEngine nodeEngine, AtomicReferenceService service)
           
 
Method Summary
 void alter(IFunction<E,E> function)
          Alters the currently stored reference by applying a function on it.
 E alterAndGet(IFunction<E,E> function)
          Alters the currently stored reference by applying a function on it and gets the result.
<R> R
apply(IFunction<E,R> function)
          Applies a function on the value, the actual stored value will not change.
 InternalCompletableFuture<Void> asyncAlter(IFunction<E,E> function)
          Alters the currently stored reference by applying a function on it.
 InternalCompletableFuture<E> asyncAlterAndGet(IFunction<E,E> function)
          Alters the currently stored reference by applying a function on it and gets the result.
<R> InternalCompletableFuture<R>
asyncApply(IFunction<E,R> function)
          Applies a function on the value, the actual stored value will not change.
 InternalCompletableFuture<Void> asyncClear()
          Clears the current stored reference.
 InternalCompletableFuture<Boolean> asyncCompareAndSet(E expect, E update)
          Atomically sets the value to the given updated value only if the current value == the expected value.
 InternalCompletableFuture<Boolean> asyncContains(E value)
          Checks if the reference contains the value.
 InternalCompletableFuture<E> asyncGet()
          Gets the current value.
 InternalCompletableFuture<E> asyncGetAndAlter(IFunction<E,E> function)
          Alters the currently stored reference by applying a function on it on and gets the old value.
 InternalCompletableFuture<E> asyncGetAndSet(E newValue)
          Gets the value and sets the new value.
 InternalCompletableFuture<Boolean> asyncIsNull()
          Checks if the stored reference is null.
 InternalCompletableFuture<Void> asyncSet(E newValue)
          Atomically sets the given value.
 InternalCompletableFuture<E> asyncSetAndGet(E update)
          Sets and gets the value.
 void clear()
          Clears the current stored reference.
 boolean compareAndSet(E expect, E update)
          Atomically sets the value to the given updated value only if the current value == the expected value.
 boolean contains(E expected)
          Checks if the reference contains the value.
 E get()
          Gets the current value.
 E getAndAlter(IFunction<E,E> function)
          Alters the currently stored reference by applying a function on it on and gets the old value.
 E getAndSet(E newValue)
          Gets the old value and sets the new value.
 String getName()
          Returns the unique name for this DistributedObject.
 int getPartitionId()
           
 String getServiceName()
          Returns the service name for this object.
 boolean isNull()
          Checks if the stored reference is null.
 void set(E newValue)
          Atomically sets the given value.
 E setAndGet(E update)
          Sets and gets the value.
 String toString()
           
 
Methods inherited from class com.hazelcast.spi.AbstractDistributedObject
destroy, equals, getId, getNameAsPartitionAwareData, getNodeEngine, getPartitionKey, getService, hashCode, invalidate, postDestroy, throwNotActiveException
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.hazelcast.core.DistributedObject
destroy, getId, getPartitionKey
 

Constructor Detail

AtomicReferenceProxy

public AtomicReferenceProxy(String name,
                            NodeEngine nodeEngine,
                            AtomicReferenceService service)
Method Detail

alter

public void alter(IFunction<E,E> function)
Description copied from interface: IAtomicReference
Alters the currently stored reference by applying a function on it.

Specified by:
alter in interface IAtomicReference<E>
Parameters:
function - the function that alters the currently stored reference

asyncAlter

public InternalCompletableFuture<Void> asyncAlter(IFunction<E,E> function)
Description copied from interface: AsyncAtomicReference
Alters the currently stored reference by applying a function on it.

Specified by:
asyncAlter in interface AsyncAtomicReference<E>
Parameters:
function - the function

alterAndGet

public E alterAndGet(IFunction<E,E> function)
Description copied from interface: IAtomicReference
Alters the currently stored reference by applying a function on it and gets the result.

Specified by:
alterAndGet in interface IAtomicReference<E>
Parameters:
function - the function that alters the currently stored reference
Returns:
the new value, the result of the applied function.

asyncAlterAndGet

public InternalCompletableFuture<E> asyncAlterAndGet(IFunction<E,E> function)
Description copied from interface: AsyncAtomicReference
Alters the currently stored reference by applying a function on it and gets the result.

Specified by:
asyncAlterAndGet in interface AsyncAtomicReference<E>
Parameters:
function - the function
Returns:
the new value.

getAndAlter

public E getAndAlter(IFunction<E,E> function)
Description copied from interface: IAtomicReference
Alters the currently stored reference by applying a function on it on and gets the old value.

Specified by:
getAndAlter in interface IAtomicReference<E>
Parameters:
function - the function that alters the currently stored reference
Returns:
the old value, the value before the function is applied

asyncGetAndAlter

public InternalCompletableFuture<E> asyncGetAndAlter(IFunction<E,E> function)
Description copied from interface: AsyncAtomicReference
Alters the currently stored reference by applying a function on it on and gets the old value.

Specified by:
asyncGetAndAlter in interface AsyncAtomicReference<E>
Parameters:
function - the function
Returns:
the old value

apply

public <R> R apply(IFunction<E,R> function)
Description copied from interface: IAtomicReference
Applies a function on the value, the actual stored value will not change.

Specified by:
apply in interface IAtomicReference<E>
Parameters:
function - the function applied on the value, the stored value does not change
Returns:
the result of the function application

asyncApply

public <R> InternalCompletableFuture<R> asyncApply(IFunction<E,R> function)
Description copied from interface: AsyncAtomicReference
Applies a function on the value, the actual stored value will not change.

Specified by:
asyncApply in interface AsyncAtomicReference<E>
Parameters:
function - the function
Returns:
the result of the function application

clear

public void clear()
Description copied from interface: IAtomicReference
Clears the current stored reference.

Specified by:
clear in interface IAtomicReference<E>

asyncClear

public InternalCompletableFuture<Void> asyncClear()
Description copied from interface: AsyncAtomicReference
Clears the current stored reference.

Specified by:
asyncClear in interface AsyncAtomicReference<E>

compareAndSet

public boolean compareAndSet(E expect,
                             E update)
Description copied from interface: IAtomicReference
Atomically sets the value to the given updated value only if the current value == the expected value.

Specified by:
compareAndSet in interface IAtomicReference<E>
Parameters:
expect - the expected value
update - the new value
Returns:
true if successful; or false if the actual value was not equal to the expected value.

asyncCompareAndSet

public InternalCompletableFuture<Boolean> asyncCompareAndSet(E expect,
                                                             E update)
Description copied from interface: AsyncAtomicReference
Atomically sets the value to the given updated value only if the current value == the expected value.

Specified by:
asyncCompareAndSet in interface AsyncAtomicReference<E>
Parameters:
expect - the expected value
update - the new value
Returns:
true if successful; or false if the actual value was not equal to the expected value.

get

public E get()
Description copied from interface: IAtomicReference
Gets the current value.

Specified by:
get in interface IAtomicReference<E>
Returns:
the current value

asyncGet

public InternalCompletableFuture<E> asyncGet()
Description copied from interface: AsyncAtomicReference
Gets the current value.

Specified by:
asyncGet in interface AsyncAtomicReference<E>
Returns:
the current value

contains

public boolean contains(E expected)
Description copied from interface: IAtomicReference
Checks if the reference contains the value.

Specified by:
contains in interface IAtomicReference<E>
Parameters:
expected - the value to check (is allowed to be null).
Returns:
true if the value is found, false otherwise.

asyncContains

public InternalCompletableFuture<Boolean> asyncContains(E value)
Description copied from interface: AsyncAtomicReference
Checks if the reference contains the value.

Specified by:
asyncContains in interface AsyncAtomicReference<E>
Parameters:
value - the value to check (is allowed to be null).
Returns:
true if the value is found, false otherwise.

set

public void set(E newValue)
Description copied from interface: IAtomicReference
Atomically sets the given value.

Specified by:
set in interface IAtomicReference<E>
Parameters:
newValue - the new value

asyncSet

public InternalCompletableFuture<Void> asyncSet(E newValue)
Description copied from interface: AsyncAtomicReference
Atomically sets the given value.

Specified by:
asyncSet in interface AsyncAtomicReference<E>
Parameters:
newValue - the new value

getAndSet

public E getAndSet(E newValue)
Description copied from interface: IAtomicReference
Gets the old value and sets the new value.

Specified by:
getAndSet in interface IAtomicReference<E>
Parameters:
newValue - the new value.
Returns:
the old value.

asyncGetAndSet

public InternalCompletableFuture<E> asyncGetAndSet(E newValue)
Description copied from interface: AsyncAtomicReference
Gets the value and sets the new value.

Specified by:
asyncGetAndSet in interface AsyncAtomicReference<E>
Parameters:
newValue - the new value.
Returns:
the old value.

setAndGet

public E setAndGet(E update)
Description copied from interface: IAtomicReference
Sets and gets the value.

Specified by:
setAndGet in interface IAtomicReference<E>
Parameters:
update - the new value
Returns:
the new value

asyncSetAndGet

public InternalCompletableFuture<E> asyncSetAndGet(E update)
Description copied from interface: AsyncAtomicReference
Sets and gets the value.

Specified by:
asyncSetAndGet in interface AsyncAtomicReference<E>
Parameters:
update - the new value
Returns:
the new value

isNull

public boolean isNull()
Description copied from interface: IAtomicReference
Checks if the stored reference is null.

Specified by:
isNull in interface IAtomicReference<E>
Returns:
true if null, false otherwise.

asyncIsNull

public InternalCompletableFuture<Boolean> asyncIsNull()
Description copied from interface: AsyncAtomicReference
Checks if the stored reference is null.

Specified by:
asyncIsNull in interface AsyncAtomicReference<E>
Returns:
true if null, false otherwise.

getName

public String getName()
Description copied from interface: DistributedObject
Returns the unique name for this DistributedObject. The returned value will never be null.

Specified by:
getName in interface DistributedObject
Returns:
the unique name for this object.

getPartitionId

public int getPartitionId()

getServiceName

public String getServiceName()
Description copied from interface: DistributedObject
Returns the service name for this object.

Specified by:
getServiceName in interface DistributedObject
Specified by:
getServiceName in class AbstractDistributedObject<AtomicReferenceService>
Returns:
the service name for this object.

toString

public String toString()
Overrides:
toString in class AbstractDistributedObject<AtomicReferenceService>


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.