Here you can find the source of getMethod(Class> clazz, String methodName, Class> fieldType)
private static Method getMethod(Class<?> clazz, String methodName, Class<?> fieldType) throws NoSuchMethodException
//package com.java2s; /******************************************************************************* * Copyright (c) 2010-2014 SAP AG and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors://from w w w . j ava 2 s. c o m * SAP AG - initial API and implementation *******************************************************************************/ import java.lang.reflect.Method; public class Main { private static Method getMethod(Class<?> clazz, String methodName, Class<?> fieldType) throws NoSuchMethodException { String name = fieldType.getSimpleName(); if ("Boolean".equals(name)) { return clazz.getMethod(methodName, boolean.class); } if ("Integer".equals(name)) { return clazz.getMethod(methodName, int.class); } if ("Long".equals(name)) { return clazz.getMethod(methodName, long.class); } if ("Float".equals(name)) { return clazz.getMethod(methodName, float.class); } if ("Double".equals(name)) { return clazz.getMethod(methodName, double.class); } if ("Character".equals(name)) { return clazz.getMethod(methodName, char.class); } return clazz.getMethod(methodName, fieldType); } }