Package com.groiss.ds

Class ComparablePair<F extends Comparable<F>,S>

java.lang.Object
com.groiss.ds.Pair<F,S>
com.groiss.ds.ComparablePair<F,S>
All Implemented Interfaces:
KeyValuePair<F,S>, Serializable, Comparable<ComparablePair<F,?>>

public class ComparablePair<F extends Comparable<F>,S> extends Pair<F,S> implements Comparable<ComparablePair<F,?>>
The comparable pair represents a pair of a key and a value. The key is used for comparing, the value is used for the toString method. This is useful if you want to sort a list be the keys and show the values. For example: new ComparablePair(dateval, CalUtil.showDate(dateval))
See Also:
  • Constructor Details

    • ComparablePair

      public ComparablePair(F key, S value)
      Constructor with key and value
      Parameters:
      key -
      value -
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Pair<F extends Comparable<F>,S>
    • compareTo

      public int compareTo(ComparablePair<F,?> o)
      Specified by:
      compareTo in interface Comparable<F extends Comparable<F>>
    • equals

      public boolean equals(Object obj)
      Description copied from class: Pair
      Returns true if obj is also a Pair and contains two objects equal to the two objects of this Pair. null references are considered as equal, too.
      Overrides:
      equals in class Pair<F extends Comparable<F>,S>
    • hashCode

      public int hashCode()
      Description copied from class: Pair
      Builds a new hash code out of the two objects' hash codes.
      Overrides:
      hashCode in class Pair<F extends Comparable<F>,S>