Here you can find the source of getMethodByReturnType(final Class> source, final Class> type)
public static Method getMethodByReturnType(final Class<?> source, final Class<?> type)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Method; public class Main { public static Method getMethodByReturnType(final Class<?> source, final Class<?> type) { for (final Method e : source.getDeclaredMethods()) { if (e.getReturnType().isAssignableFrom(type)) { return e; }/*from w w w .ja v a 2 s. com*/ } return null; } }