Package com.axelor.common
Class Inflections
- java.lang.Object
-
- com.axelor.common.Inflections
-
public class Inflections extends Object
TheInflections
defines rules for singular, plural inflections.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
apply(String word, List<com.axelor.common.Inflections.Rule> rules)
Apply the given list of inflection rules on the provided word.static Inflections
getInstance()
Get the default instance ofInflections
for the English.static Inflections
getInstance(String language)
Get the default instance ofInflections
for the given language.void
ignore(String... words)
Add words to ignore for inflections.void
irregular(String singular, String plural)
Add irregular singular, plural words.void
plural(String pattern, String replacement)
Add rule for converting singular to plural.String
pluralize(String word)
Convert the given word to it's plural form.void
singular(String pattern, String replacement)
Add rule for converting plurals to singular.String
singularize(String word)
Convert the given word to it's singular form.
-
-
-
Method Detail
-
getInstance
public static Inflections getInstance()
Get the default instance ofInflections
for the English.- Returns:
- an instance of
Inflections
-
getInstance
public static Inflections getInstance(String language)
Get the default instance ofInflections
for 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
-
-