Here you can find the source of getGetterMethod(Class> clazz, String propertyName)
public static Method getGetterMethod(Class<?> clazz, String propertyName)
//package com.java2s; /**/*from ww w .ja va 2s . c o m*/ * Copyright 2008 Autentia Real Business Solutions S.L. * * This file is part of autentia-util. * * autentia-util is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * autentia-util is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with autentia-util. If not, see <http://www.gnu.org/licenses/>. */ import java.lang.reflect.Method; public class Main { public static Method getGetterMethod(Class<?> clazz, String propertyName) { final String camelCase = propertyName.substring(0, 1).toUpperCase() + propertyName.substring(1); String getterName = "get" + camelCase; Method getterMethod; try { getterMethod = clazz.getMethod(getterName); } catch (Exception e) { getterName = "is" + camelCase; try { getterMethod = clazz.getMethod(getterName); } catch (Exception e1) { return null; } } return getterMethod; } }