
// this class is used by class HashMap, and it must remain immutable because of this
class KeyValuePair {
  private Object key, value;
  
  public KeyValuePair( Object key, Object value ) {
    this.key = key;
    this.value = value;
  }
  
  public Object getKey() {
    return key;
  }
  
  public Object getValue() {
    return value;
  }

  public boolean hasKey( Object key ) {
    if ( this.key == null && key == null )
      return true;
    else if ( this.key == null || key == null )
      return false;
    else
      return this.key.equals( key );
  }

  public boolean hasValue( Object value ) {
    if ( this.value == null && value == null )
      return true;
    else if ( this.value == null || value == null )
      return false;
    else
      return this.value.equals( value );
  }

  public String toString() {
    return "(" + key + ", " + value + ")";
  }
}
