Class Inflections


  • public class Inflections
    extends Object
    The Inflections defines rules for singular, plural inflections.
    • Method Detail

      • getInstance

        public static Inflections getInstance​(String language)
        Get the default instance of Inflections 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 word
        plural - the plural word
      • singular

        public void singular​(String pattern,
                             String replacement)
        Add rule for converting plurals to singular.
        Parameters:
        pattern - the pattern to match plural
        replacement - the replacement text
      • plural

        public void plural​(String pattern,
                           String replacement)
        Add rule for converting singular to plural.
        Parameters:
        pattern - the pattern to match singular
        replacement - 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 rules
        rules - 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
      • pluralize

        public String pluralize​(String word)
        Convert the given word to it's plural form.
        Parameters:
        word - the word to convert
        Returns:
        the converted text