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

Java examples for Reflection:Getter

Description

Return the getter method name for the given property name.

Demo Code


//package com.java2s;

public class Main {
    /**//from   w  ww  .  j  a  v a2s .c o m
     * Return the getter method name for the given property name.
     *
     * @param property the property name
     * @return the getter method name for the given property name.
     */
    public static String toGetterName(String property) {
        StringBuilder buffer = new StringBuilder(property.length() + 3);

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

        return buffer.toString();
    }
}

Related Tutorials