org.multiverse.transactional.primitives
Class TransactionalInteger

java.lang.Object
  extended by org.multiverse.transactional.primitives.TransactionalInteger

public final class TransactionalInteger
extends Object

A transactional primitive for a int.

Author:
Peter Veentjer

Constructor Summary
TransactionalInteger()
          Creates a new TransactionalInteger with the 0 as value.
TransactionalInteger(int value)
          Creates a new TransactionalInteger with the given value.
 
Method Summary
 void await(int desired)
          Waits till the value is equal to the desired value.
 int awaitLargerOrEqualThan(int than)
          Waits till the value is equal or larger than.
 int awaitLargerThan(int than)
          Waits till this value is larger than.
 int awaitNotEqualTo(int than)
           
 int awaitSmallerOrEqualThan(int than)
           
 int awaitSmallerThan(int than)
           
 int dec()
          Decreases the value in this TransactionalInteger by one.
 int dec(int amount)
          Decreases the value of this TransactionalInteger by the given amount.
 boolean equals(Object thatObj)
           
 int get()
          Gets the current value.
 int hashCode()
           
 int inc()
          Increases the value in this TransactionalInteger by one.
 int inc(int amount)
          Increase the value of this TransactionalInteger by the given amount.
 int set(int newValue)
          Sets the new value and returns the old value.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransactionalInteger

public TransactionalInteger()
Creates a new TransactionalInteger with the 0 as value.


TransactionalInteger

public TransactionalInteger(int value)
Creates a new TransactionalInteger with the given value.

Parameters:
value - the initial value of this TransactionalInteger.
Method Detail

get

public int get()
Gets the current value.

Returns:
gets the current value.

set

public int set(int newValue)
Sets the new value and returns the old value.

Parameters:
newValue - the new value.
Returns:
the previous value.

dec

public int dec()
Decreases the value in this TransactionalInteger by one.

Returns:
the decreased value.

inc

public int inc()
Increases the value in this TransactionalInteger by one.

Returns:
the increased value.

inc

public int inc(int amount)
Increase the value of this TransactionalInteger by the given amount.

Parameters:
amount - the amount the value needs to be increased with. Value is allowed to be 0 or negative.
Returns:
the increased value.

dec

public int dec(int amount)
Decreases the value of this TransactionalInteger by the given amount.

Parameters:
amount - the amount the value needs to be decreased with. Value is allowed to be 0 or negative.
Returns:
the decreased value.

await

public void await(int desired)
Waits till the value is equal to the desired value.

Parameters:
desired - the value to wait for.

awaitLargerThan

public int awaitLargerThan(int than)
Waits till this value is larger than.

Parameters:
than - the value to wait for.
Returns:
the value that currently is active.

awaitLargerOrEqualThan

public int awaitLargerOrEqualThan(int than)
Waits till the value is equal or larger than.

Parameters:
than -
Returns:

awaitSmallerThan

public int awaitSmallerThan(int than)

awaitSmallerOrEqualThan

public int awaitSmallerOrEqualThan(int than)

awaitNotEqualTo

public int awaitNotEqualTo(int than)

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object thatObj)
Overrides:
equals in class Object


Copyright © 2008-2010 Multiverse. All Rights Reserved.