org.jjoost.util
Class Counters.SerialCounter

java.lang.Object
  extended by org.jjoost.util.Counters.SerialCounter
All Implemented Interfaces:
Counter
Enclosing class:
Counters

public static class Counters.SerialCounter
extends java.lang.Object
implements Counter

Returns a regular Counter which performs ordinary addition with no concurrency guarantees

Author:
b.elliottsmith

Constructor Summary
Counters.SerialCounter()
           
 
Method Summary
 boolean add(int i)
          returns true if adding the provided integer does not reduce the value to below zero; if true then the value was added to the Counter
 int get()
          Gets the current value of the Counter
 Counter newInstance()
          returns a new Counter of the same type as this one, with a value of zero
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Counters.SerialCounter

public Counters.SerialCounter()
Method Detail

add

public boolean add(int i)
Description copied from interface: Counter
returns true if adding the provided integer does not reduce the value to below zero; if true then the value was added to the Counter

Specified by:
add in interface Counter
Parameters:
i - to add
Returns:
true, if successful

get

public int get()
Description copied from interface: Counter
Gets the current value of the Counter

Specified by:
get in interface Counter
Returns:
current value

newInstance

public Counter newInstance()
Description copied from interface: Counter
returns a new Counter of the same type as this one, with a value of zero

Specified by:
newInstance in interface Counter
Returns:
new Counter