Class NameValue<T>

java.lang.Object
se.datadosen.util.NameValue<T>
All Implemented Interfaces:
Serializable, Comparable

public class NameValue<T> extends Object implements Serializable, Comparable
Class that allows an arbitrary value to be tagged along a visible string Enables for instance JComboBoxes to display strings but also supply an arbitrary value with each item Similar to Item, but with the visible name being in focus (i.e. equals(), hashCode() and compareTo() considers the visible name and not the value)
Since:
v11
See Also:
  • Field Details

    • name

      public final String name
    • value

      public final T value
  • Constructor Details

    • NameValue

      public NameValue(String name, T value)
  • Method Details

    • equals

      public boolean equals(Object obj)
      Compares to other NameValues (considering name only) or to other Strings
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(Object o)
      Specified by:
      compareTo in interface Comparable<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object