Java String Pluralize pluralize(final String s)

Here you can find the source of pluralize(final String s)

Description

pluralize

License

Apache License

Declaration

public static String pluralize(final String s) 

Method Source Code

//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;
    }
}

Related

  1. pluralise(String str)
  2. pluralise(String string, double size)
  3. pluraliseInc(int num, String word)
  4. pluraliseNoun(String noun, long count, boolean forceAppendingSByDefault)
  5. pluralize(final int count, final String singular, final String plural)
  6. pluralize(final String typeName)
  7. pluralize(int count, final String singular, final String plural)
  8. pluralize(int count, String single)
  9. pluralize(int count, String singular)