Class NameValue<T>

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

public class NameValue<T>
extends java.lang.Object
implements java.io.Serializable, java.lang.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:
Serialized Form
  • Field Summary

    Fields 
    Modifier and Type Field Description
    java.lang.String name  
    T value  
  • Constructor Summary

    Constructors 
    Constructor Description
    NameValue​(java.lang.String name, T value)  
  • Method Summary

    Modifier and Type Method Description
    int compareTo​(java.lang.Object o)  
    boolean equals​(java.lang.Object obj)
    Compares to other NameValues (considering name only) or to other Strings
    int hashCode()  
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      public final java.lang.String name
    • value

      public final T value
  • Constructor Details

    • NameValue

      public NameValue​(java.lang.String name, T value)
  • Method Details

    • equals

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

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

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

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object