List of utility methods to do String Pluralize
String | plural(int amount) Is it second, or seconds? return amount == 1 ? " " : "s "; |
String | plural(int count, String word, String ending) Return plural word if count is bigger than one return count == 1 ? word : word + ending;
|
String | plural(int nb) plural return nb > 1 ? "s" : ""; |
String | plural(int number, String form1, String form2, String form3) This method return plural form of word based on int value. int n1 = Math.abs(number) % 100; int n2 = number % 10; if (n1 > 10 && n1 < 20) return form3; if (n2 > 1 && n2 < 5) return form2; if (n2 == 1) return form1; ... |
String | plural(int size, String name) plural return "" + size + " " + name + (size > 1 ? "s" : ""); |
String | plural(String arg) plural if (arg == null) { return ""; try { double a = Double.valueOf(arg); if (a == 1.0) { return ""; } else { ... |
String | plural(String objectName) plural return objectName.endsWith("y") ? objectName.substring(0, objectName.length() - 1) + "ies" : objectName + "s"; |
String | plural(String singular) plural if (singular == null || singular.length() == 0) { return singular; if (singular.equalsIgnoreCase("person")) { return singular.charAt(0) + "eople"; } else if (singular.equalsIgnoreCase("child")) { return singular.charAt(0) + "hildren"; } else if (singular.equalsIgnoreCase("alumnus")) { ... |
String | plural(String str, String suffix, int count) plural if (count == 1) return str; else return str + suffix; |
String | plural(String strSingle, String strPlural, int amount) plural return String.format(amount == 1 ? strSingle : strPlural, amount);
|