Package org.jboss.util
Class LongCounter
- java.lang.Object
-
- org.jboss.util.LongCounter
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
LongCounter.Wrapper
public class LongCounter extends java.lang.Object implements java.io.Serializable, java.lang.CloneableA long integer counter class.- Version:
- $Revision$
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classLongCounter.WrapperBase wrapper class for other wrappers.
-
Field Summary
Fields Modifier and Type Field Description private longcountThe current countprivate static longserialVersionUIDThe serialVersionUID
-
Constructor Summary
Constructors Constructor Description LongCounter()Construct a LongCounter.LongCounter(long count)Construct a LongCounter with a starting value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Return a cloned copy of this object.longdecrement()Decrement the counter.booleanequals(java.lang.Object obj)Check if the given object is equal to this.longgetCount()Return the current value of the counter.longincrement()Increment the counter.static LongCountermakeDirectional(LongCounter counter, boolean increasing)Returns a directional counter.static LongCountermakeSynchronized(LongCounter counter)Return a synchronized counter.voidreset()Reset the counter to zero.java.lang.StringtoString()Return a string representation of this.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
The serialVersionUID- See Also:
- Constant Field Values
-
count
private long count
The current count
-
-
Method Detail
-
increment
public long increment()
Increment the counter. (Optional operation)- Returns:
- The incremented value of the counter.
-
decrement
public long decrement()
Decrement the counter. (Optional operation)- Returns:
- The decremented value of the counter.
-
getCount
public long getCount()
Return the current value of the counter.- Returns:
- The current value of the counter.
-
reset
public void reset()
Reset the counter to zero. (Optional operation)
-
equals
public boolean equals(java.lang.Object obj)
Check if the given object is equal to this.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- Object to test equality with.- Returns:
- True if object is equal to this.
-
toString
public java.lang.String toString()
Return a string representation of this.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of this.
-
clone
public java.lang.Object clone()
Return a cloned copy of this object.- Overrides:
clonein classjava.lang.Object- Returns:
- A cloned copy of this object.
-
makeSynchronized
public static LongCounter makeSynchronized(LongCounter counter)
Return a synchronized counter.- Parameters:
counter- LongCounter to synchronize.- Returns:
- Synchronized counter.
-
makeDirectional
public static LongCounter makeDirectional(LongCounter counter, boolean increasing)
Returns a directional counter.- Parameters:
counter- LongCounter to make directional.increasing- True to create an increasing only or false to create a decreasing only.- Returns:
- A directional counter.
-
-