Return the setter method name for the given property name. - Java Reflection

Java examples for Reflection:Setter

Description

Return the setter method name for the given property name.

Demo Code


//package com.java2s;

public class Main {
    /**//from w  w w . ja v  a  2 s  .  c  o m
     * Return the setter method name for the given property name.
     *
     * @param property the property name
     * @return the setter method name for the given property name.
     */
    public static String toSetterName(String property) {
        StringBuilder buffer = new StringBuilder(property.length() + 3);

        buffer.append("set");
        buffer.append(Character.toUpperCase(property.charAt(0)));
        buffer.append(property.substring(1));

        return buffer.toString();
    }
}

Related Tutorials