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

Stringpluralise(String str)
Returns a pluralised version of the given String
if (str == null) {
    return null;
return str + "s";
Stringpluralise(String string, double size)
pluralise
return size > 1 ? string + (string.endsWith("s") ? "es" : "s") : string;
StringpluraliseInc(int num, String word)
Returns the given word, pluralised by adding a postfix 's' if applicable, and prefixed by the given number.
return num + " " + pluralise(num, word);
StringpluraliseNoun(String noun, long count, boolean forceAppendingSByDefault)
Performs naive pluralisation of the supplied noun.
if (count % 10 != 1 || count == 11) {
    if (!forceAppendingSByDefault && noun.endsWith("y")) {
        return (noun.substring(0, noun.length() - 1) + "ies"); 
    } else {
        return (noun + "s"); 
} else {
    return noun;
...
Stringpluralize(final int count, final String singular, final String plural)
Returns the plural word, unless count is 1 or -1.
switch (count) {
case -1:
case 1:
    return String.format(singular, count);
default:
    return String.format(plural, count);
Stringpluralize(final String s)
pluralize
String _xifexpression = null;
boolean _endsWith = s.endsWith("y");
if (_endsWith) {
    int _length = s.length();
    int _minus = (_length - 1);
    String _substring = s.substring(0, _minus);
    _xifexpression = (_substring + "ies");
} else {
...
Stringpluralize(final String typeName)
pluralize
if (typeName == null) {
    throw new IllegalArgumentException("typeName");
if (typeName.endsWith("y")) {
    return typeName.substring(0, typeName.length() - 1).concat("ies");
} else if (typeName.endsWith("s")) {
    return typeName;
} else if (typeName.equalsIgnoreCase("staff")) {
...
Stringpluralize(int count, final String singular, final String plural)
Returns the singular or plural form of a string, based on the count.
if (count == 1)
    return singular;
return (plural != null) ? plural : singular + 's';
Stringpluralize(int count, String single)
Return the count and the quantity label as a properly pluralized string.
if (count == 1) {
    return NumberFormat.getNumberInstance().format(count) + " " + single;
} else {
    return NumberFormat.getNumberInstance().format(count) + " " + single + "s";
Stringpluralize(int count, String singular)
Pluralize the singular word, unless count == 1, and concatenate it to the count.
return count + " " + pluralize(singular, count);