Record Class SearchWord

java.lang.Object
java.lang.Record
fr.becpg.repo.helper.SearchWord
Record Components:
raw - the word as typed
stem - the word without its plural or feminine ending

record SearchWord(String raw, String stem) extends Record
A word of a free-text search, kept both as typed and reduced to a common form, so that a plural, a feminine or an irregular form finds its base word while a word being typed still finds the words it starts. The word is expected lower-cased and without accents.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final List<Map.Entry<Pattern,String>>
    Endings rewritten, in this order, to reach the common form: English "-ies" plural, French "-aux" plural of an "-al" word (but not "-eaux", the plural of "-eau"), "s" or "x" plural, then the "-ee" of a feminine past participle.
    private final String
    The field for the raw record component.
    private final String
    The field for the stem record component.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SearchWord(String raw, String stem)
    Creates an instance of a SearchWord record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    (package private) boolean
    Tells whether a typed word starts this word, as typed or in its common form.
    (package private) static SearchWord
    of(String word)
    Builds the search word of a lower-cased, accent-free word.
    raw()
    Returns the value of the raw record component.
    Returns the value of the stem record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • raw

      private final String raw
      The field for the raw record component.
    • stem

      private final String stem
      The field for the stem record component.
    • ENDING_RULES

      private static final List<Map.Entry<Pattern,String>> ENDING_RULES
      Endings rewritten, in this order, to reach the common form: English "-ies" plural, French "-aux" plural of an "-al" word (but not "-eaux", the plural of "-eau"), "s" or "x" plural, then the "-ee" of a feminine past participle. A short word is left untouched, to keep "les", "taux" or "pies" readable.
  • Constructor Details

    • SearchWord

      SearchWord(String raw, String stem)
      Creates an instance of a SearchWord record class.
      Parameters:
      raw - the value for the raw record component
      stem - the value for the stem record component
  • Method Details

    • of

      static SearchWord of(String word)
      Builds the search word of a lower-cased, accent-free word.
      Parameters:
      word - the word
      Returns:
      the word with its common form
    • isStartedBy

      boolean isStartedBy(SearchWord prefix)
      Tells whether a typed word starts this word, as typed or in its common form.
      Parameters:
      prefix - the typed word
      Returns:
      true when this word starts with it
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • raw

      public String raw()
      Returns the value of the raw record component.
      Returns:
      the value of the raw record component
    • stem

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