Java Reflection Field Find findFieldOfTypeInClass(final Class source, final Class type)

Here you can find the source of findFieldOfTypeInClass(final Class source, final Class type)

Description

find Field Of Type In Class

License

Open Source License

Declaration

public static Field findFieldOfTypeInClass(final Class<?> source, final Class<?> type) 

Method Source Code

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

Related

  1. findFieldInClass(Class clazz, String fieldName)
  2. findFieldInClassHierarchy(Class clazz, String fieldName)
  3. findFieldIncludeSuperclass(String fieldName, Class clazz)
  4. findFieldInternal(Class currentClass, Class annotation, Set fields)
  5. findFieldOfBean(Object bean, String fieldName)
  6. findFieldRecursively(Class c, String fieldName)
  7. findFields(Class c, boolean allowTransient, int max, Iterable> fieldClassesToFind, Iterable> exceptClasses)
  8. findFields(Class type)
  9. findFields(final Class clazz, final Predicate filter)