Here you can find the source of pluralize(final int count, final String singular, final String plural)
plural
word, unless count
is 1 or -1.
Parameter | Description |
---|---|
count | The magnitude. |
singular | The singular. |
plural | The plural. |
(count == 1 || count == -1) ? singular : plural
public static final String pluralize(final int count, final String singular, final String plural)
//package com.java2s; /**/*from w w w. j a v a 2 s . c o m*/ * Copyright (C) 2013, University of Manchester and University of Southampton * * Licensed under the GNU Lesser General Public License v2.1 * See the "LICENSE" file that is distributed with the source code for license terms. */ public class Main { /** * Returns the <code>plural</code> word, unless <code>count</code> is 1 or -1. * In which case, the <code>singular</code> word is returned. * * @param count The magnitude. * @param singular The singular. * @param plural The plural. * @return <code>(count == 1 || count == -1) ? singular : plural</code> */ public static final String pluralize(final int count, final String singular, final String plural) { switch (count) { case -1: case 1: return String.format(singular, count); default: return String.format(plural, count); } } }