Java Reflection Method Name getMethod(Class clazz, String methodName, Class fieldType)

Here you can find the source of getMethod(Class clazz, String methodName, Class fieldType)

Description

get Method

License

Open Source License

Declaration

private static Method getMethod(Class<?> clazz, String methodName, Class<?> fieldType)
            throws NoSuchMethodException 

Method Source Code

//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);
    }
}

Related

  1. getMethod(Class beanClass, String methodName, Class[] types)
  2. getMethod(Class c, String name)
  3. getMethod(Class c, String name)
  4. getMethod(Class c, String name, Class[] args)
  5. getMethod(Class clazz, String methodName)
  6. getMethod(Class clazz, String methodName, Class... arguments)
  7. getMethod(Class clazz, String methodName, Class... params)
  8. getMethod(Class clazz, String methodName, Class... params)
  9. getMethod(Class clazz, String methodName, Class... params)