Here you can find the source of pluralize(String name)
Parameter | Description |
---|---|
name | base name |
public static String pluralize(String name)
//package com.java2s; public class Main { /**// w w w. jav a2 s. c o m * Convert singular name to plural form. TODO: internationalization? * * @param name base name * @return plural name */ public static String pluralize(String name) { // first check for already in plural form if (name.endsWith("List") || (name.endsWith("s") && !name.endsWith("ss"))) { return name; } // convert singular form to plural if (name.endsWith("y") && !name.endsWith("ay") && !name.endsWith("ey") && !name.endsWith("iy") && !name.endsWith("oy") && !name.endsWith("uy")) { if (name.equalsIgnoreCase("any")) { return name; } else { return name.substring(0, name.length() - 1) + "ies"; } } else if (name.endsWith("ss")) { return name + "es"; } else { return name + 's'; } } }