Here you can find the source of findField(final String className, final String fieldName)
Parameter | Description |
---|---|
className | the class name |
fieldName | the field name |
public static Field findField(final String className, final String fieldName)
//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; } }