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