2.17.2: 2011-06-17

net.sf.basedb.util.units
Class UnitCache.CacheKey

java.lang.Object
  extended by net.sf.basedb.util.units.UnitCache.CacheKey
All Implemented Interfaces:
Comparable<UnitCache.CacheKey>
Enclosing class:
UnitCache

static class UnitCache.CacheKey
extends Object
implements Comparable<UnitCache.CacheKey>

Units are cached by (quantity,symbol) combination. This class is used as keys to the cache and overrides the equals and hashcode methods to makes sure that two keys with the same quantity and symbol are considered equal.

This class also implements the comparable interface so that it is possible to sort units in the order of their symbols. If two symbols are equal the one with the lowes quantity id is sorted first.


Field Summary
private  int quantityId
           
private  String symbol
           
 
Constructor Summary
UnitCache.CacheKey(int quantityId, String symbol)
           
 
Method Summary
 int compareTo(UnitCache.CacheKey o)
           
 boolean equals(Object other)
           
 int hashCode()
          From the Object class ---------------------
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

quantityId

private final int quantityId

symbol

private final String symbol
Constructor Detail

UnitCache.CacheKey

UnitCache.CacheKey(int quantityId,
                   String symbol)
Method Detail

hashCode

public int hashCode()
From the Object class ---------------------

Overrides:
hashCode in class Object

equals

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

compareTo

public int compareTo(UnitCache.CacheKey o)
Specified by:
compareTo in interface Comparable<UnitCache.CacheKey>

2.17.2: 2011-06-17