Here you can find the source of findFieldOfTypeInClass(final Class> source, final Class> type)
public static Field findFieldOfTypeInClass(final Class<?> source, final Class<?> type)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; public class Main { public static Field findFieldOfTypeInClass(final Class<?> source, final Class<?> type) { for (final Field e : source.getDeclaredFields()) { if (e.getType().equals(type)) { e.setAccessible(true);/*from w w w . j ava 2 s .co m*/ return e; } } return null; } }