Explorar el Código

add constValue that grabs the value of a field by name

tags/2.0.1
Jonathan Cobb hace 5 años
padre
commit
006bcd1ff4
Se han modificado 1 ficheros con 12 adiciones y 0 borrados
  1. +12
    -0
      src/main/java/org/cobbzilla/util/reflect/ReflectionUtil.java

+ 12
- 0
src/main/java/org/cobbzilla/util/reflect/ReflectionUtil.java Ver fichero

@@ -1155,4 +1155,16 @@ public class ReflectionUtil {
}
}

public static <T> T constValue(Class type, String fieldName) {
final Field field;
try {
field = type.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
return null;
} catch (Exception e) {
return die("constValue: "+e);
}
return constValue(field);
}

}

Cargando…
Cancelar
Guardar