Here you can find the source of pluralize(String input)
public static String pluralize(String input)
//package com.java2s; //License from project: Open Source License public class Main { /** Pluralize a property name, which is smart about things like nouns ending in 's' or 'y'. * *//*from ww w . j a va 2 s . c o m*/ public static String pluralize(String input) { // See http://firstschoolyears.com/literacy/word/other/plurals/resources/rules.htm for a decent list of rules 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"; } else if (input.endsWith("o")) { return input + "es"; } else if (input.endsWith("y") && !isVowel(input.charAt(input.length() - 2))) { result = input.substring(0, input.length() - 1).concat("ies"); } else { result = input.concat("s"); } return result; } private static boolean isVowel(char c) { char lower = Character.toLowerCase(c); return lower == 'a' || lower == 'e' || lower == 'i' || lower == 'o' || lower == 'u'; } }