Here you can find the source of pluralize(String singular, long number)
Parameter | Description |
---|---|
singular | the singular to 'pluralize' |
number | if this equals 1, no s is added |
public static String pluralize(String singular, long number)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010, 2012 Institute for Dutch Lexicology * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.// w ww . j av a2 s. c om *******************************************************************************/ public class Main { /** * Return the singular or the plural form of a noun depending on a number. * * This version of the method simply appends an "s" to form the plural. * For irregular plural forms, use the version that takes 3 parameters. * * @param singular the singular to 'pluralize' * @param number if this equals 1, no s is added * @return the possibly pluralized form */ public static String pluralize(String singular, long number) { return pluralize(singular, singular + "s", number); } /** * Return the singular or the plural form of a noun depending on a number. * * @param singular the singular form of the word * @param plural the plural form of the word * @param number if this equals 1, the sinular is returned, otherwise the plural * @return the possibly pluralized form */ public static String pluralize(String singular, String plural, long number) { return number == 1 ? singular : plural; } }