Here you can find the source of plural(String word, Number cardinality)
public static String plural(String word, Number cardinality)
//package com.java2s; /*/* www .j av a 2s . c o m*/ * This file is part of ConfigHub. * * ConfigHub is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ConfigHub is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.??See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ConfigHub.??If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Returns the plural form of the specified word if cardinality * != 1. The plural form is is generated by concatenating the letter * 's' to the end of the word, unless the word ends in an h, s, or x. * In these cases, 'es' is added to form the plural. * <p> * This method assumes that the word is not already plural. */ public static String plural(String word, Number cardinality) { String suffix = "s"; char lastChar = word.charAt(word.length() - 1); if (lastChar == 'h' || lastChar == 's' || lastChar == 'x') { suffix = "es"; } return plural(word, suffix, cardinality); } public static String plural(String word, String suffix, Number cardinality) { if (cardinality.doubleValue() == 1) { return word; } return word + suffix; } }