Java String Pluralize pluralize(int count, String singular, String plural)

Here you can find the source of pluralize(int count, String singular, String plural)

Description

Returns a singlular or pluralized word.

License

Open Source License

Parameter

Parameter Description
count count to base if the word should be treated as singular or plural
singular single version of the word
plural plural version of the word

Return

pluralized String

Declaration

public static String pluralize(int count, String singular, String plural) 

Method Source Code

//package com.java2s;
/*// www  .  j  ava2 s.co m
 * Copyright (c) 2013 Washington State Department of Transportation
 *
 * This program 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.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */

public class Main {
    /**
     * Returns a singlular or pluralized word.
     * 
     * @param count count to base if the word should be treated as singular or plural
     * @param singular single version of the word
     * @param plural plural version of the word
     * @return pluralized String
     */
    public static String pluralize(int count, String singular, String plural) {
        return (count == 1 ? singular : plural);
    }
}

Related

  1. pluralize(final String typeName)
  2. pluralize(int count, final String singular, final String plural)
  3. pluralize(int count, String single)
  4. pluralize(int count, String singular)
  5. pluralize(int count, String singular, String plural)
  6. pluralize(int count, String word)
  7. Pluralize(int quantity, String units)
  8. pluralize(int value, CharSequence singularForm, CharSequence pluralForm)
  9. pluralize(long count, String singularFormat, String pluralFormat)