Package opennlp.spellcheck

# Record Class SuggestItem

java.lang.Object
java.lang.Record
opennlp.spellcheck.SuggestItem

Record Components:
  `term` - the suggested (corrected) term; never `null`
  `editDistance` - the edit distance between the suggestion and the queried term
  `frequency` - the corpus frequency (count) of the suggested term

All Implemented Interfaces:
  `Comparable<SuggestItem>`

public record SuggestItem(String term, int editDistance, long frequency) extends Record implements Comparable<SuggestItem>
An immutable spelling suggestion produced by a `SpellChecker`.

The natural ordering sorts by ascending `editDistance()` first, then by descending `frequency()`, and finally by the `term()` as a tie-breaker, so the best candidate sorts first. The term tie-breaker keeps the natural ordering consistent with `equals(Object)`: two items compare equal only when they are equal, so distinct suggestions that tie on distance and frequency are never silently dropped from a `TreeSet` or `TreeMap`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SuggestItem(String term, int editDistance, long frequency)`
  Creates an instance of a `SuggestItem` record class.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compareTo(SuggestItem other)`
  `int`
  `editDistance()`
  Returns the value of the `editDistance` record component.
  `final boolean`
  `equals(Object o)`
  Indicates whether some other object is "equal to" this one.
  `long`
  `frequency()`
  Returns the value of the `frequency` record component.
  `final int`
  `hashCode()`
  Returns a hash code value for this object.
  `String`
  `term()`
  Returns the value of the `term` record component.
  `final String`
  `toString()`
  Returns a string representation of this record class.

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### SuggestItem

    public SuggestItem(String term, int editDistance, long frequency)
    Creates an instance of a `SuggestItem` record class.
    Parameters:
      `term` - the value for the `term` record component
      `editDistance` - the value for the `editDistance` record component
      `frequency` - the value for the `frequency` record component

- ## Method Details

  - ### compareTo

    public int compareTo(SuggestItem other)
    Specified by:
      `compareTo` in interface `Comparable<SuggestItem>`

  - ### toString

    public final String toString()
    Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
    Specified by:
      `toString` in class `Record`
    Returns:
      a string representation of this object

  - ### hashCode

    public final int hashCode()
    Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
    Specified by:
      `hashCode` in class `Record`
    Returns:
      a hash code value for this object

  - ### equals

    public final boolean equals(Object o)
    Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with `Objects::equals(Object,Object)`; primitive components are compared with '=='.
    Specified by:
      `equals` in class `Record`
    Parameters:
      `o` - the object with which to compare
    Returns:
      `true` if this object is the same as the `o` argument; `false` otherwise.

  - ### term

    public String term()
    Returns the value of the `term` record component.
    Returns:
      the value of the `term` record component

  - ### editDistance

    public int editDistance()
    Returns the value of the `editDistance` record component.
    Returns:
      the value of the `editDistance` record component

  - ### frequency

    public long frequency()
    Returns the value of the `frequency` record component.
    Returns:
      the value of the `frequency` record component