org.expasy.jpl.commons.base
Class CounterImpl

java.lang.Object
  extended by org.expasy.jpl.commons.base.CounterImpl
All Implemented Interfaces:
Serializable, Cloneable, Counter, ExplicitlyCloneable, Resetable

public final class CounterImpl
extends Object
implements Counter, Resetable, ExplicitlyCloneable, Serializable

CounterImpl is a simple counter and a better alternative than Integer as a new instance is created each time you want to set the value.

Version:
1.0
Author:
nikitin
See Also:
Serialized Form

Method Summary
 CounterImpl clone()
          Creates and returns a copy of this CounterImpl.
 void decrement()
          Decrement counter by 1.
 void decrement(int dec)
          Decrement counter by dec.
 boolean equals(Object o)
           
 int getCount()
           
 int hashCode()
           
 void increment()
          Increment counter by 1.
 void increment(int inc)
          Increment counter by inc.
static CounterImpl newInstance()
          A basic static factory method.
 void reset()
          reinitialising object
 String toString()
           
static CounterImpl valueOf(int start)
          A type-conversion static factory method.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

newInstance

public static CounterImpl newInstance()
A basic static factory method.

Returns:
a new instance of CounterImpl initialized to 0.

valueOf

public static CounterImpl valueOf(int start)
A type-conversion static factory method.

Returns:
a new instance of CounterImpl with the given value.

reset

public void reset()
Description copied from interface: Resetable
reinitialising object

Specified by:
reset in interface Resetable
See Also:
Resetable.reset()

clone

public CounterImpl clone()
Creates and returns a copy of this CounterImpl.

Specified by:
clone in interface ExplicitlyCloneable
Overrides:
clone in class Object
See Also:
Object.clone()

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

increment

public void increment()
Increment counter by 1.

Specified by:
increment in interface Counter

increment

public void increment(int inc)
Increment counter by inc.

Specified by:
increment in interface Counter

decrement

public void decrement()
Decrement counter by 1.

Specified by:
decrement in interface Counter

decrement

public void decrement(int dec)
Decrement counter by dec.

Specified by:
decrement in interface Counter

getCount

public int getCount()
Specified by:
getCount in interface Counter
Returns:
counter value.

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2012 Swiss Institute of Bioinformatics. All rights reserved.