Java Reflection Field Find findField(final String className, final String fieldName)

Here you can find the source of findField(final String className, final String fieldName)

Description

Find field.

License

Open Source License

Parameter

Parameter Description
className the class name
fieldName the field name

Return

the field

Declaration

public static Field findField(final String className, final String fieldName) 

Method Source Code


//package com.java2s;
import java.lang.reflect.Field;

import java.util.LinkedHashMap;

import java.util.Map;

public class Main {
    /** The field mapping. */
    private static Map<String, Field[]> fieldMapping = new LinkedHashMap<String, Field[]>();

    /**//ww  w  . java  2 s.  co  m
     * Find field.
     * 
     * @param className
     *            the class name
     * @param fieldName
     *            the field name
     * @return the field
     */
    public static Field findField(final String className, final String fieldName) {
        Field[] fields = fieldMapping.get(className);
        for (Field field : fields) {
            if (field.getName().equals(fieldName)) {
                return field;
            }
        }
        return null;
    }
}

Related

  1. findField(final Class currentClass, final String fieldName)
  2. findField(final Class declaringClass, final String fieldName)
  3. findField(final Class klaz, final String fieldName)
  4. findField(final Object instance, final String name)
  5. findField(final Object src, final String fieldName)
  6. findField(Object container, String memberName)
  7. findField(Object instance, String name)
  8. findField(Object obj, String beanPath)
  9. findField(Object obj, String fieldName)