org.jfree.data

Class DefaultKeyedValue

Implemented Interfaces:
Cloneable, KeyedValue, PublicCloneable, Serializable, Value

public class DefaultKeyedValue
extends java.lang.Object
implements KeyedValue, Cloneable, PublicCloneable, Serializable

A (key, value) pair. This class provides a default implementation of the KeyedValue interface.

Constructor Summary

DefaultKeyedValue(Comparable key, Number value)
Creates a new (key, value) item.

Method Summary

Object
clone()
Returns a clone.
boolean
equals(Object obj)
Tests this key-value pair for equality with an arbitrary object.
Comparable
getKey()
Returns the key.
Number
getValue()
Returns the value.
int
hashCode()
Returns a hash code.
void
setValue(Number value)
Sets the value.

Constructor Details

DefaultKeyedValue

public DefaultKeyedValue(Comparable key,
                         Number value)
Creates a new (key, value) item.
Parameters:
key - the key (should be immutable).
value - the value (null permitted).

Method Details

clone

public Object clone()
            throws CloneNotSupportedException
Returns a clone. It is assumed that both the key and value are immutable objects, so only the references are cloned, not the objects themselves.
Returns:
A clone.

equals

public boolean equals(Object obj)
Tests this key-value pair for equality with an arbitrary object.
Parameters:
obj - the object (null permitted).
Returns:
A boolean.

getKey

public Comparable getKey()
Returns the key.
Specified by:
getKey in interface KeyedValue
Returns:
The key.

getValue

public Number getValue()
Returns the value.
Specified by:
getValue in interface Value
Returns:
The value (possibly null).

hashCode

public int hashCode()
Returns a hash code.
Returns:
A hash code.

setValue

public void setValue(Number value)
Sets the value.
Parameters:
value - the value (null permitted).