Java Utililty Methods String Plural

List of utility methods to do String Plural

Description

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

Method

StringtoPlural(String _str)
to Plural
String plural;
if (_str != null && _str.length() > 0) {
    char ch = _str.charAt(_str.length() - 1);
    StringBuffer pluralBuffer = new StringBuffer(_str);
    if (ch == 's' || ch == 'x') {
        pluralBuffer.append("es");
    } else if (ch == 'y') {
        pluralBuffer.setLength(pluralBuffer.length() - 1);
...
StringtoPlural(String candidate)
Converts string to plural form
if (candidate.length() >= 1 && !candidate.endsWith("s")) {
    return candidate + "s";
return candidate;
StringtoPlural(String name)
to Plural
if (name.endsWith("y")) {
    int length = name.length();
    name = name.substring(0, length - 2);
    return name + "ies";
if (name.endsWith("s"))
    return name + "es";
if (name.equalsIgnoreCase("child"))
...
StringtoPlural(String name)
to Plural
if (name.endsWith("y")) {
    if (name.length() > 1)
        return name.substring(0, name.length() - 1) + "ies";
    else
        return "ys";
} else if (name.endsWith("x")) {
    if (name.length() > 1)
        return name + "es";
...
StringtoPluralForm(String propertyName)
to Plural Form
String endString;
if (propertyName.endsWith("Parson") || propertyName.endsWith("parson")) {
    propertyName = propertyName.replace("Parson", "");
    propertyName = propertyName.replace("parson", "");
    if ("".equals(propertyName)) {
        endString = "people";
    } else {
        endString = "People";
...