Class Score<K>

  • Type Parameters:
    K - The type of the key.
    All Implemented Interfaces:
    java.lang.Comparable<Score<K>>

    public class Score<K>
    extends java.lang.Object
    implements java.lang.Comparable<Score<K>>
    A class that maintains and integer score and type for a key.
    Version:
    1.0, 21.05.2008
    Author:
    Ralf Duckstein
    • Constructor Summary

      Constructors 
      Constructor Description
      Score​(K key)
      Creates a score without type and value 0.
      Score​(K key, int score)
      Creates a score without type.
      Score​(K key, int score, java.lang.String type)
      Creates a score with one type.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int addScore​(int add)
      Increases the score by add.
      void addType​(java.lang.String type)
      Adds an additional type.
      int compareTo​(Score<K> s)
      Compares the score to another score.
      K getKey()
      Returns the key.
      int getScore()
      Returns the score.
      java.lang.String getType()
      Returns the (first) type.
      java.util.Collection<java.lang.String> getTypes()
      Returns a collection of all types.
      int setScore​(int score)
      Changes the score to score.
      java.lang.String setType​(java.lang.String type)
      Sets the type.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Score

        public Score​(K key)
        Creates a score without type and value 0.
      • Score

        public Score​(K key,
                     int score)
        Creates a score without type.
      • Score

        public Score​(K key,
                     int score,
                     java.lang.String type)
        Creates a score with one type.
    • Method Detail

      • getKey

        public K getKey()
        Returns the key.
      • getScore

        public int getScore()
        Returns the score.
      • addScore

        public int addScore​(int add)
        Increases the score by add.
      • setScore

        public int setScore​(int score)
        Changes the score to score.
      • getType

        public java.lang.String getType()
        Returns the (first) type.
      • setType

        public java.lang.String setType​(java.lang.String type)
        Sets the type.
      • addType

        public void addType​(java.lang.String type)
        Adds an additional type.
      • getTypes

        public java.util.Collection<java.lang.String> getTypes()
        Returns a collection of all types. The first value will always be getType().
      • compareTo

        public int compareTo​(Score<K> s)
        Compares the score to another score. Partial order, so it violates contracts of compareTo(), equals() and hashCode()!
        Specified by:
        compareTo in interface java.lang.Comparable<K>
        Returns:
        1 if this score is greater than s
        See Also:
        Comparable.compareTo(java.lang.Object)
      • toString

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