Java Setter Name Create toSetterName(String fieldName)

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

Description

to Setter Name

License

Apache License

Declaration

public static String toSetterName(String fieldName) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static String toSetterName(String fieldName) {
        return toAccessorName(fieldName, "set");
    }//from   w ww . j av  a 2 s  .  co m

    private static String toAccessorName(String fieldName, String accessorTypeName) {
        if (fieldName == null || fieldName.equals("")) {
            throw new IllegalArgumentException("argument is empty");
        }
        String ret = fieldName.substring(0, 1).toUpperCase();
        if (fieldName.length() > 1) {
            ret = ret + fieldName.substring(1);
        }
        return accessorTypeName + ret;
    }
}

Related

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