Class DefaultKeyedValue<K extends Comparable<K>>

java.lang.Object
org.jfree.data.DefaultKeyedValue<K>
Type Parameters:
K - the key type (String is 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 the KeyedValue interface.
See Also:
  • Constructor Details

    • DefaultKeyedValue

      public DefaultKeyedValue(K key, Number value)
      Creates a new (key, value) item.
      Parameters:
      key - the key (should be immutable, null not permitted).
      value - the value (null permitted).
  • Method Details

    • getKey

      public K getKey()
      Returns the key.
      Specified by:
      getKey in interface KeyedValue<K extends Comparable<K>>
      Returns:
      The key (never null).
    • getValue

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

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

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

      public int hashCode()
      Returns a hash code.
      Overrides:
      hashCode in class Object
      Returns:
      A hash code.
    • clone

      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:
      clone in interface PublicCloneable
      Overrides:
      clone in class Object
      Returns:
      A clone.
      Throws:
      CloneNotSupportedException - Not thrown by this class, but subclasses (if any) might.
    • toString

      public String toString()
      Returns a string representing this instance, primarily useful for debugging.
      Overrides:
      toString in class Object
      Returns:
      A string.