Here you can find the source of pluralize(final String s)
public static String pluralize(final String s)
//package com.java2s; /**/*from ww w.java 2s. c o m*/ * Copyright 2016 California Institute of Technology ("Caltech"). * U.S. Government sponsorship acknowledged. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * License Terms */ public class Main { public static String pluralize(final String s) { String _xifexpression = null; boolean _endsWith = s.endsWith("y"); if (_endsWith) { int _length = s.length(); int _minus = (_length - 1); String _substring = s.substring(0, _minus); _xifexpression = (_substring + "ies"); } else { String _xifexpression_1 = null; boolean _endsWith_1 = s.endsWith("x"); if (_endsWith_1) { _xifexpression_1 = (s + "es"); } else { String _xifexpression_2 = null; boolean _endsWith_2 = s.endsWith("s"); if (_endsWith_2) { _xifexpression_2 = s; } else { _xifexpression_2 = (s + "s"); } _xifexpression_1 = _xifexpression_2; } _xifexpression = _xifexpression_1; } return _xifexpression; } }