Java Setter Name Create toSetterName(String property)

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

Description

to Setter Name

License

Open Source License

Declaration

public static String toSetterName(String property) 

Method Source Code

//package com.java2s;
/*/*from   w  ww. ja  va2 s . co  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 toSetterName(String property) {
        StringBuffer setterName = new StringBuffer();

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

        return setterName.toString();
    }
}

Related

  1. toSetterName(String field)
  2. toSetterName(String fieldName)
  3. toSetterName(String name)