Java Java String Format toJavaBeanPropertyName(String prop)

Here you can find the source of toJavaBeanPropertyName(String prop)

Description

Whenever a property name starts with a single lowercase letter, the actual java bean property starts with an upper case letter.

License

Open Source License

Parameter

Parameter Description
prop the property name.

Return

the fixed java bean property name.

Declaration

public static String toJavaBeanPropertyName(String prop) 

Method Source Code

//package com.java2s;
/*/* www.  j a  v a  2  s .  c om*/
 * Copyright (c) 2005-2016 Vincent Vandenschrick. All rights reserved.
 *
 *  This file is part of the Jspresso framework.
 *
 *  Jspresso is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Jspresso is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with Jspresso.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Whenever a property name starts with a single lowercase letter, the actual
     * java bean property starts with an upper case letter.
     *
     * @param prop
     *     the property name.
     * @return the fixed java bean property name.
     */
    public static String toJavaBeanPropertyName(String prop) {
        if (prop != null && prop.length() >= 2) {
            if (Character.isLowerCase(prop.charAt(0)) && Character.isUpperCase(prop.charAt(1))) {
                StringBuilder fixedProp = new StringBuilder(prop.substring(0, 1).toUpperCase());
                fixedProp.append(prop.substring(1));
                return fixedProp.toString();
            }
        }
        return prop;
    }
}

Related

  1. toJava(CharSequence str)
  2. toJava(final double[] doubles)
  3. toJava(String name)
  4. toJava(String text)
  5. toJAVA(String unicode)
  6. toJavaBool(byte goBool)
  7. toJavaCasing(final String pName)
  8. toJavaClassName(String str)
  9. toJavaConstantIdentifier(String name)