Package fr.becpg.repo.helper
Record Class SearchWord
java.lang.Object
java.lang.Record
fr.becpg.repo.helper.SearchWord
- Record Components:
raw- the word as typedstem- the word without its plural or feminine ending
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
FieldsModifier and TypeFieldDescriptionEndings 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 static final StringFeminine ending of an adjective, which a typed plural may lack: "végétaux" for "végétale".private final StringThe field for therawrecord component.private final StringThe field for thestemrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionSearchWord(String raw, String stem) Creates an instance of aSearchWordrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.private booleanTells whether one of the ending rules rewrote this word.(package private) booleanisSameWordAs(SearchWord word) Tells whether a typed word is this word, as typed or in its common form.(package private) booleanisStartedBy(SearchWord prefix) Tells whether a typed word starts this word, as typed or in its common form.(package private) static SearchWordBuilds the search word of a lower-cased, accent-free word.raw()Returns the value of therawrecord component.stem()Returns the value of thestemrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
raw
The field for therawrecord component. -
stem
The field for thestemrecord component. -
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. -
FEMININE_ENDING
Feminine ending of an adjective, which a typed plural may lack: "végétaux" for "végétale".- See Also:
-
-
Constructor Details
-
Method Details
-
of
Builds the search word of a lower-cased, accent-free word.- Parameters:
word- the word- Returns:
- the word with its common form
-
isStartedBy
Tells whether a typed word starts this word, as typed or in its common form. A typed word whose ending was rewritten, such as the plural "lacs", is a complete word: it finds its common form in either gender ("lac", "végétale" for "végétaux") but no longer word ("lactose").- Parameters:
prefix- the typed word- Returns:
- true when this word starts with it
-
hasRewrittenEnding
private boolean hasRewrittenEnding()Tells whether one of the ending rules rewrote this word.- Returns:
- true when the common form differs from the word
-
isSameWordAs
Tells whether a typed word is this word, as typed or in its common form.- Parameters:
word- the typed word- Returns:
- true when both words are the same
-
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
raw
Returns the value of therawrecord component.- Returns:
- the value of the
rawrecord component
-
stem
Returns the value of thestemrecord component.- Returns:
- the value of the
stemrecord component
-