Android Utililty Methods Class Field Find

List of utility methods to do Class Field Find


The list of methods to do Class Field Find are organized into topic(s).


FieldfindField(Class clazz, String fieldName)
Look up a field in a class and set it to accessible.
StringBuilder sb = new StringBuilder(clazz.getName());
String fullFieldName = sb.toString();
if (fieldCache.containsKey(fullFieldName)) {
    Field field = fieldCache.get(fullFieldName);
    if (field == null)
        throw new NoSuchFieldError(fullFieldName);
FieldfindFieldRecursiveImpl(Class clazz, String fieldName)
find Field Recursive Impl
try {
    return clazz.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
    while (true) {
        clazz = clazz.getSuperclass();
        if (clazz == null || clazz.equals(Object.class))
        try {
FieldfindFirstFieldByExactType(Class clazz, Class type)
Returns the first field of the given type in a class.
Class<?> clz = clazz;
do {
    for (Field field : clz.getDeclaredFields()) {
        if (field.getType() == type) {
            return field;
} while ((clz = clz.getSuperclass()) != null);
throw new NoSuchFieldError("Field of type " + type.getName()
        + " in class " + clazz.getName());
ObjectgetAdditionalStaticField(Class clazz, String key)
get Additional Static Field
return getAdditionalInstanceField(clazz, key);
Field[]getFields(Class cs)
get Fields
List<Field> fieldList = new ArrayList<Field>();
Class<?> c = cs;
while (c != null) {
    Field[] fields = c.getDeclaredFields();
    for (Field field : fields) {
    c = c.getSuperclass();