org.jjoost.util
Interface Counter

All Known Implementing Classes:
Counters.DontCounter, Counters.SerialCounter, Counters.ThreadSafeCounter

public interface Counter

A simple interface encapsulating some dynamic integer greater than or equal to zero

Author:
b.elliottsmith

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
 

Method Detail

add

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

Parameters:
i - to add
Returns:
true, if successful

get

int get()
Gets the current value of the Counter

Returns:
current value

newInstance

Counter newInstance()
returns a new Counter of the same type as this one, with a value of zero

Returns:
new Counter