You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Marc Johnson <ma...@hotmail.com> on 2002/01/17 18:23:56 UTC
[NEW CLASS -- NOTHING TO PATCH]: LocalTestNode.java
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
package org.apache.commons.collections;
/**
* Class LocalTestNode
*
* a helper class for TestDoubleOrderedMap
*
* @author Marc Johnson (marcj at users dot sourceforge dot net)
*/
class LocalTestNode implements Comparable {
private Comparable key;
private Comparable value;
/**
* construct a LocalTestNode
*
* @param key value used to create the key and value
*/
LocalTestNode(final int key) {
this.key = new Integer(key);
this.value = String.valueOf(key);
}
/**
* @param key the unique key associated with the current node.
*/
void setKey(Comparable key) {
this.key = key;
}
/**
* @return the unique key associated with the current node
*/
Comparable getKey() {
return key;
}
/**
* @param value the unique value associated with the current node.
*/
void setValue(Comparable value) {
this.value = value;
}
/**
* @return the unique value associated with the current node
*/
Comparable getValue() {
return value;
}
/**
* Method compareTo
*
* @param o
*
* @return
*/
public int compareTo(Object o) {
LocalTestNode other = (LocalTestNode) o;
int rval = getKey().compareTo(other.getKey());
if (rval == 0) {
rval = getValue().compareTo(other.getValue());
}
return rval;
}
/**
* Method equals
*
* @param o
*
* @return true if equal
*/
public boolean equals(Object o) {
if (o == null) {
return false;
}
if (!(o.getClass().equals(this.getClass()))) {
return false;
}
LocalTestNode node = (LocalTestNode) o;
return (getKey().equals(node.getKey())
&& getValue().equals(node.getValue()));
}
/**
* @return hash code
*/
public int hashCode() {
return getKey().hashCode() ^ getValue().hashCode();
}
}
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>