Package org.jfree.data
Class DefaultKeyedValue
- java.lang.Object
-
- org.jfree.data.DefaultKeyedValue
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,KeyedValue,Value,org.jfree.util.PublicCloneable
public class DefaultKeyedValue extends java.lang.Object implements KeyedValue, java.lang.Cloneable, org.jfree.util.PublicCloneable, java.io.Serializable
A (key, value) pair. This class provides a default implementation of theKeyedValueinterface.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultKeyedValue(java.lang.Comparable key, java.lang.Number value)Creates a new (key, value) item.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Returns a clone.booleanequals(java.lang.Object obj)Tests this key-value pair for equality with an arbitrary object.java.lang.ComparablegetKey()Returns the key.java.lang.NumbergetValue()Returns the value.inthashCode()Returns a hash code.voidsetValue(java.lang.Number value)Sets the value.java.lang.StringtoString()Returns a string representing this instance, primarily useful for debugging.
-
-
-
Constructor Detail
-
DefaultKeyedValue
public DefaultKeyedValue(java.lang.Comparable key, java.lang.Number value)
Creates a new (key, value) item.- Parameters:
key- the key (should be immutable,nullnot permitted).value- the value (nullpermitted).
-
-
Method Detail
-
getKey
public java.lang.Comparable getKey()
Returns the key.- Specified by:
getKeyin interfaceKeyedValue- Returns:
- The key (never
null).
-
getValue
public java.lang.Number getValue()
Returns the value.
-
setValue
public void setValue(java.lang.Number value)
Sets the value.- Parameters:
value- the value (nullpermitted).
-
equals
public boolean equals(java.lang.Object obj)
Tests this key-value pair for equality with an arbitrary object.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the object (nullpermitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hash code.- Overrides:
hashCodein classjava.lang.Object- Returns:
- A hash code.
-
clone
public java.lang.Object clone() throws java.lang.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.- Specified by:
clonein interfaceorg.jfree.util.PublicCloneable- Overrides:
clonein classjava.lang.Object- Returns:
- A clone.
- Throws:
java.lang.CloneNotSupportedException- Not thrown by this class, but subclasses (if any) might.
-
toString
public java.lang.String toString()
Returns a string representing this instance, primarily useful for debugging.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string.
-
-