Procházet zdrojové kódy

add constValue that grabs the value of a field by name

tags/2.0.1
Jonathan Cobb před 5 roky
rodič
revize
006bcd1ff4
1 změnil soubory, kde provedl 12 přidání a 0 odebrání
  1. +12
    -0
      src/main/java/org/cobbzilla/util/reflect/ReflectionUtil.java

+ 12
- 0
src/main/java/org/cobbzilla/util/reflect/ReflectionUtil.java Zobrazit soubor

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

}

Načítá se…
Zrušit
Uložit