Java Getter Name Create toGetterName(String property)

Here you can find the source of toGetterName(String property)

Description

to Getter Name

License

Open Source License

Declaration

public static String toGetterName(String property) 

Method Source Code

//package com.java2s;
/*//  w  ww  .j  a  v  a2s  .c  o  m
   Milyn - Copyright (C) 2006 - 2010
    
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License (version 2.1) as published by the Free Software
   Foundation.
    
   This library 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:
   http://www.gnu.org/licenses/lgpl.txt
*/

public class Main {
    public static String toGetterName(String property) {
        StringBuffer getterName = new StringBuffer();

        // Add the property string to the buffer...
        getterName.append(property);
        // Uppercase the first character...
        getterName.setCharAt(0, Character.toUpperCase(property.charAt(0)));
        // Prefix with "get"...
        getterName.insert(0, "get");

        return getterName.toString();
    }
}

Related

  1. toGetter(String fieldName)
  2. toGetter(String name)
  3. toGetterMethodName(String s)
  4. toGetterName(String name)
  5. toGetterName(String name)
  6. toGetterString(String str)