Class Count<K extends Comparable<K>>

java.lang.Object
org.deltava.util.Count<K>
Type Parameters:
K - the label class
All Implemented Interfaces:
Comparable<Count<?>>

public class Count<K extends Comparable<K>> extends Object implements Comparable<Count<?>>
A counter class that has a label and a counter.
Since:
12.4
Version:
12.4
Author:
Luke
  • Constructor Details

    • Count

      public Count(K label)
      Creates the counter.
      Parameters:
      label - the label
  • Method Details

    • labelComparator

      public static <K extends Comparable<K>> Comparator<Count<K>> labelComparator(Class<K> c)
      Returns a comparator that compares based on label, rather than value.
      Parameters:
      c - the generic class
      Returns:
      a Comparator
    • inc

      public void inc()
      Increments the counter.
    • getLabel

      public K getLabel()
      Returns the counter label.
      Returns:
      the label
    • getValue

      public int getValue()
      Returns the counter value.
      Returns:
      the value
    • compareTo

      public int compareTo(Count<?> c2)
      Specified by:
      compareTo in interface Comparable<K extends Comparable<K>>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object