Java Utililty Methods String Pluralize

List of utility methods to do String Pluralize

Description

The list of methods to do String Pluralize are organized into topic(s).

Method

Stringpluralize(int count, String singular, String plural)
Select singular or plural string based upon count.
return (count == 1) ? singular : plural;
Stringpluralize(int count, String singular, String plural)
Returns a singlular or pluralized word.
return (count == 1 ? singular : plural);
Stringpluralize(int count, String word)
pluralize
return count == 1 ? word : word + 's';
StringPluralize(int quantity, String units)
Pluralize
if (quantity == 1) {
    return quantity + " " + units;
} else {
    return quantity + " " + units + "s ";
Stringpluralize(int value, CharSequence singularForm, CharSequence pluralForm)
pluralize
return Integer.toString(value) + " " + (value == 1 ? singularForm : pluralForm);
Stringpluralize(long count, String singularFormat, String pluralFormat)
pluralize
return Math.abs(count) == 1 ? String.format(singularFormat, count) : String.format(pluralFormat, count);
Stringpluralize(long strictlyPositiveCount, String singular, String plural)
pluralize
if (strictlyPositiveCount == 1) {
    return "1 " + singular + " ago";
return strictlyPositiveCount + " " + plural + " ago";
Stringpluralize(long val, String singular, String plural)
Determines whether the singular or plural version of a word should be used.
return (val == 1) ? singular : plural;
Stringpluralize(String base, int quantity)
pluralize
if (quantity == 1)
    return base;
else if (base.trim().toLowerCase().endsWith("s"))
    return base + "es";
else
    return base + "s";
Stringpluralize(String input)
Pluralize a property name, which is smart about things like nouns ending in 's' or 'y'.
String result;
if (input.endsWith("ife")) {
    return input.substring(0, input.length() - 3) + "ives";
} else if (input.endsWith("s") || input.endsWith("sh") || input.endsWith("ch") || input.endsWith("x")
        || input.endsWith("z")) {
    result = input.concat("es");
} else if (input.endsWith("f") && !input.substring(input.length() - 2, 1).matches("[efo]")) {
    return input.substring(0, input.length() - 1) + "ves";
...