package username.dict; /** * Key/Value pairs, used in many implementations of dictionaries. * * @author Samuel A. Rebelsky * @version 1.0 of April 2006. */ class KeyedValue { // +------------------+------------------------------------- // | Design Decisions | // +------------------+ /* (1) KeyedValue has "package" protection; it is intended only for direct access by other members of the username.dict package. (2) Since KeyedValue is not intended for general access, the clients of this class may use the fields directly. Hence, their are neither setters nor getters. */ // +--------+----------------------------------------------- // | Fields | // +--------+ /** * The key of the pair. */ K key; /** * The value of the pair. */ V value; // +--------------+----------------------------------------- // | Constructors | // +--------------+ KeyedValue(K _key, V _value) { this.key = _key; this.value = _value; } // KeyedValue(K,V) // +------------------+------------------------------------- // | Standard Methods | // +------------------+ public String toString() { return this.key.toString() + " => " + this.value.toString(); } // toString() public boolean equals(KeyedValue other) { return this.key.equals(other.key); } // equals(KeyedValue) } // class KeyedValue