Class Suggestion

  • All Implemented Interfaces:
    java.lang.Comparable<Suggestion>

    final class Suggestion
    extends java.lang.Object
    implements java.lang.Comparable<Suggestion>
    This class hold one Suggestion for another spelling. Note: this class has a natural ordering that is inconsistent with equals.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int diff  
      private java.lang.String word  
    • Constructor Summary

      Constructors 
      Constructor Description
      Suggestion​(java.lang.CharSequence word, int diff)
      Construct a suggestion
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Suggestion sugg)
      boolean equals​(java.lang.Object sugg)
      int getDissimilarity()
      Return a value that descript dissimilarity to the original word.
      java.lang.String getWord()
      Get the suggested word.
      int hashCode()
      java.lang.String toString()
      Return the suggested word and it equals to getWord().
      • Methods inherited from class java.lang.Object

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

      • word

        private final java.lang.String word
      • diff

        private final int diff
    • Constructor Detail

      • Suggestion

        Suggestion​(java.lang.CharSequence word,
                   int diff)
        Construct a suggestion
        Parameters:
        word - the characters of the suggested the word.
        diff - the difference to the original word.
    • Method Detail

      • toString

        public java.lang.String toString()
        Return the suggested word and it equals to getWord().
        Overrides:
        toString in class java.lang.Object
      • getWord

        public java.lang.String getWord()
        Get the suggested word.
        Returns:
        the word
      • getDissimilarity

        public int getDissimilarity()
        Return a value that descript dissimilarity to the original word. A vaulue of 0 means that the value is 100% identical. This should not occur.
        Returns:
        the dissimilarity, so larger to differ the word.
      • equals

        public boolean equals​(java.lang.Object sugg)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public int compareTo​(Suggestion sugg)
        Specified by:
        compareTo in interface java.lang.Comparable<Suggestion>