集册 Java实例教程 返回给定属性名称的is getter方法名称。

返回给定属性名称的is getter方法名称。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

395
返回给定属性名称的is getter方法名称。
//n o w j a v a . c o m - 时代Java


//package com.nowjava;


public class Main {

    /**

     * Return the is getter method name for the given property name.

     *

     * @param property the property name

     * @return the is getter method name for the given property name.

     */

    public static String toIsGetterName(String property) {

        StringBuilder buffer = new StringBuilder(property.length() + 3);


        buffer.append("is");

        buffer.append(Character.toUpperCase(property.charAt(0)));

        buffer.append(property.substring(1));


        return buffer.toString();

    }

}