Java String Singularize singularOrPlural(int testValue, String singular, String plural)

Here you can find the source of singularOrPlural(int testValue, String singular, String plural)

Description

Returns the singular or plural string based on the test value

License

GNU General Public License

Parameter

Parameter Description
testValue integer that's either 1 or something else
singular what to return if 1
plural what to return if something other than 1

Return

singular or plural string

Declaration

public static String singularOrPlural(int testValue, String singular, String plural) 

Method Source Code

//package com.java2s;
/** This class is a PanelLeft factory, creating all panels based on the
 * contents of the panels.xml file./*from   ww  w . j  a va2 s .  c  om*/
 *
 * Last Updated:  May 25, 2011
 *
 * by Rick C. Hodgin
 * Cossatot Analytics Laboratories, LLC. (Cana Labs)
 *
 * (c) Copyright Cana Labs.
 * Free software licensed under the GNU GPL2.
 *
 * @author Rick C. Hodgin
 * @version 1.0.0
 *
 * Change history:
 *   2011-05-25 - 1.0.0 - Initial release
 *
 */

public class Main {
    /**
     * Returns the singular or plural string based on the test value
     * @param testValue integer that's either 1 or something else
     * @param singular what to return if 1
     * @param plural what to return if something other than 1
     * @return singular or plural string
     */
    public static String singularOrPlural(int testValue, String singular, String plural) {
        if (testValue == 1)
            return (singular);
        return (plural);
    }
}

Related

  1. singular(String plural)
  2. singularise(String name)
  3. singularize(final String buffer)
  4. singularize(String value)
  5. singularPlural(int n, String singular, String plural)
  6. SingularToPlural(String noun)