Parcourir la source

add constValue that grabs the value of a field by name

tags/2.0.1
Jonathan Cobb il y a 5 ans
Parent
révision
006bcd1ff4
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. +12
    -0
      src/main/java/org/cobbzilla/util/reflect/ReflectionUtil.java

+ 12
- 0
src/main/java/org/cobbzilla/util/reflect/ReflectionUtil.java Voir le fichier

@@ -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);
}

}

Chargement…
Annuler
Enregistrer