Here you can find the source of getGetterMethodName(String fieldName, java.lang.Class
Parameter | Description |
---|---|
fieldName | the name of the field |
fieldType | the type of the field |
private static <T> String getGetterMethodName(String fieldName, java.lang.Class<T> fieldType)
//package com.java2s; /* Copyright 2010 Google Inc. * //from www . j a va 2 s . c o m * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License */ public class Main { /** * Get the getter method names for attributes. * * @param fieldName the name of the field * @param fieldType the type of the field * @return String the name of the getter method for the field */ private static <T> String getGetterMethodName(String fieldName, java.lang.Class<T> fieldType) { String firstStringChar = fieldName.substring(0, 1).toUpperCase(); String remaingString = fieldName.substring(1); String methodName = null; /* In case the the field is a boolean */ if (fieldType != null && fieldType == boolean.class || fieldType == Boolean.class) { methodName = "is" + firstStringChar + remaingString; } else { methodName = "get" + firstStringChar + remaingString; } return methodName; } }