Browse Source

add constValue that grabs the value of a field by name

tags/2.0.1
Jonathan Cobb 5 years ago
parent
commit
006bcd1ff4
1 changed files with 12 additions and 0 deletions
  1. +12
    -0
      src/main/java/org/cobbzilla/util/reflect/ReflectionUtil.java

+ 12
- 0
src/main/java/org/cobbzilla/util/reflect/ReflectionUtil.java View File

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

} }

Loading…
Cancel
Save