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(String name)
pluralize
if (Character.isDigit(name.charAt(name.length() - 1))) {
    return name;
} else if (name.equalsIgnoreCase("children") || name.endsWith("Children")) { 
    return name;
} else if (name.equalsIgnoreCase("child") || name.endsWith("Child")) { 
    return name + "ren"; 
} else if (name.equalsIgnoreCase("data") || name.endsWith("Data")) { 
    return name;
...
Stringpluralize(String name)
Convert singular name to plural form.
if (name.endsWith("List") || (name.endsWith("s") && !name.endsWith("ss"))) {
    return name;
if (name.endsWith("y") && !name.endsWith("ay") && !name.endsWith("ey") && !name.endsWith("iy")
        && !name.endsWith("oy") && !name.endsWith("uy")) {
    if (name.equalsIgnoreCase("any")) {
        return name;
    } else {
...
Stringpluralize(String name)
pluralize
if (name.endsWith("ss")) {
    return name + "es";
} else if (!name.endsWith("s")) {
    return name + "s";
return name;
Stringpluralize(String name)
pluralize
StringBuilder pluralized = new StringBuilder(name);
return pluralized.append("s").toString();
Stringpluralize(String s)
turn String s into a plural noun (doing the right thing with "story" -> "stories" and "mess" -> "messes")
if (s.endsWith("y"))
    return s.substring(0, s.length() - 1) + "ies";
else if (s.endsWith("s"))
    return s + "es";
else
    return s + "s";
Stringpluralize(String singular, long number)
Return the singular or the plural form of a noun depending on a number.
return pluralize(singular, singular + "s", number);
Stringpluralize(String singularNoun)
Thank you, AndroMDA project...
String pluralNoun = singularNoun;
int nounLength = pluralNoun.length();
if (nounLength == 1) {
    pluralNoun = pluralNoun + 's';
} else if (nounLength > 1) {
    char secondToLastChar = pluralNoun.charAt(nounLength - 2);
    if (pluralNoun.endsWith("y")) {
        switch (secondToLastChar) {
...
Stringpluralize(String singularNoun)
pluralize
String pluralNoun;
if (singularNoun.endsWith("y") && !singularNoun.endsWith("ay") && !singularNoun.endsWith("ey")
        && !singularNoun.endsWith("oy")) {
    pluralNoun = singularNoun.substring(0, singularNoun.length() - 1) + "ies";
} else if (!singularNoun.endsWith("s")) {
    pluralNoun = singularNoun + "s";
} else {
    pluralNoun = singularNoun;
...
Stringpluralize(String suggestion)
pluralize
final String VOWELS = "aeiouy";
if (suggestion.endsWith("s") || suggestion.endsWith("x") || suggestion.endsWith("ch")) {
    suggestion += "es";
} else {
    int len = suggestion.length();
    if (suggestion.endsWith("y") && len > 1 && VOWELS.indexOf(suggestion.charAt(len - 2)) < 0) {
        suggestion = suggestion.substring(0, len - 1) + "ies";
    } else {
...
Stringpluralize(String word)
pluralize
if (word.endsWith("s") || word.endsWith("x") || word.endsWith("o") || word.endsWith("ch")) {
    return word + "es";
if (word.endsWith("y")) {
    if (word.length() == 1) {
        return word;
    char next2last = word.charAt(word.length() - 2);
...