Package com.axelor.common
Class Inflections
- java.lang.Object
-
- com.axelor.common.Inflections
-
public class Inflections extends Object
TheInflectionsdefines rules for singular, plural inflections.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Stringapply(String word, List<com.axelor.common.Inflections.Rule> rules)Apply the given list of inflection rules on the provided word.static InflectionsgetInstance()Get the default instance ofInflectionsfor the English.static InflectionsgetInstance(String language)Get the default instance ofInflectionsfor the given language.voidignore(String... words)Add words to ignore for inflections.voidirregular(String singular, String plural)Add irregular singular, plural words.voidplural(String pattern, String replacement)Add rule for converting singular to plural.Stringpluralize(String word)Convert the given word to it's plural form.voidsingular(String pattern, String replacement)Add rule for converting plurals to singular.Stringsingularize(String word)Convert the given word to it's singular form.
-
-
-
Method Detail
-
getInstance
public static Inflections getInstance()
Get the default instance ofInflectionsfor the English.- Returns:
- an instance of
Inflections
-
getInstance
public static Inflections getInstance(String language)
Get the default instance ofInflectionsfor the given language.- Parameters:
language- the language- Returns:
- an instance of
Inflections
-
ignore
public void ignore(String... words)
Add words to ignore for inflections.- Parameters:
words- the words to ignore.
-
irregular
public void irregular(String singular, String plural)
Add irregular singular, plural words.- Parameters:
singular- the singular wordplural- the plural word
-
singular
public void singular(String pattern, String replacement)
Add rule for converting plurals to singular.- Parameters:
pattern- the pattern to match pluralreplacement- the replacement text
-
plural
public void plural(String pattern, String replacement)
Add rule for converting singular to plural.- Parameters:
pattern- the pattern to match singularreplacement- the replacement text
-
apply
protected String apply(String word, List<com.axelor.common.Inflections.Rule> rules)
Apply the given list of inflection rules on the provided word.- Parameters:
word- the word on which to apply the rulesrules- the inflection rules- Returns:
- the inflected text
-
singularize
public String singularize(String word)
Convert the given word to it's singular form.- Parameters:
word- the word to convert- Returns:
- the converted text
-
-