com.rubecula.darwin.domain.world
Class Frequency

java.lang.Object
  extended by com.rubecula.darwin.domain.world.Frequency
All Implemented Interfaces:
java.lang.Comparable<Frequency>

public class Frequency
extends java.lang.Object
implements java.lang.Comparable<Frequency>

Well, sometimes Java is simply bizarre. The Integer class is immutable, and cannot be extended to allow mutability. Hence this class Frequency which isn't immutable, but can only be updated by incrementing or decrementing (no multiplication, division, etc.). Note that this type is not of the usual type family: there is no interface or abstract type to support this, hence we have public non-bean methods that are not defined in an external interface.

Author:
Robin Hillyard

Constructor Summary
Frequency()
          construct a new Frequency with value 0.
Frequency(int i)
          construct a new Frequency with value i.
 
Method Summary
 void add(int inc)
           
 int compareTo(Frequency o)
           
 void decrement()
          decrement this Frequency by one
 boolean equals(java.lang.Object obj)
           
 int hashCode()
           
 void increment()
          increment this Frequency by one
 int intValue()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Frequency

public Frequency()
construct a new Frequency with value 0.


Frequency

public Frequency(int i)
construct a new Frequency with value i.

Parameters:
i -
Method Detail

add

public void add(int inc)
Parameters:
inc - the amount to increment frequency by

compareTo

public int compareTo(Frequency o)
Specified by:
compareTo in interface java.lang.Comparable<Frequency>
See Also:
Comparable.compareTo(java.lang.Object)

decrement

public void decrement()
decrement this Frequency by one


equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

increment

public void increment()
increment this Frequency by one


intValue

public int intValue()
Returns:
the value (field i

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.