Java Reflection Method Return getMethodReturnType(Class clazz, String name)

Here you can find the source of getMethodReturnType(Class clazz, String name)

Description

get Method Return Type

License

Apache License

Declaration

public static Class<?> getMethodReturnType(Class<?> clazz, String name) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Method;

public class Main {
    public static Class<?> getMethodReturnType(Class<?> clazz, String name) {
        if (clazz == null || name == null || name.isEmpty()) {
            return null;
        }//from w w  w .j a v a2  s .  c o m

        name = name.toLowerCase();
        Class<?> returnType = null;

        for (Method method : clazz.getDeclaredMethods()) {
            if (method.getName().equals(name)) {
                returnType = method.getReturnType();
                break;
            }
        }

        return returnType;
    }
}

Related

  1. getMethodGenericReturnType(Method method, int index)
  2. getMethodInvoker(final Class returnType, final String methodName)
  3. getMethodNoArgs(final Class objClass, final String methodName, final Class... returnTypePreference)
  4. getMethodReturnType(Class clazz, String methodName)
  5. getMethodReturnType(Class clazz, String name)