@Test void getNativeIntValueThrowsOnNotFound() { Assertions.assertThrows(IllegalStateException.class, () -> LibraryFieldUtil.getNativeIntValue(EdsdkLibrary.EdsFileAttributes.class, "doNoExist")); }
public static int getNativeIntValue(final Class klass, final String fieldName) { try { final Field field = klass.getField(fieldName); return field.getInt(null); } catch (NoSuchFieldException | IllegalAccessException e) { log.error("Failed to get field value for '{}' in {}: {}", fieldName, klass, e.getMessage()); throw new IllegalStateException("Failed to get field value for '" + fieldName + "' from " + klass.getCanonicalName(), e); } }
LibraryFieldUtil { public static int getNativeIntValue(final Class klass, final String fieldName) { try { final Field field = klass.getField(fieldName); return field.getInt(null); } catch (NoSuchFieldException | IllegalAccessException e) { log.error("Failed to get field value for '{}' in {}: {}", fieldName, klass, e.getMessage()); throw new IllegalStateException("Failed to get field value for '" + fieldName + "' from " + klass.getCanonicalName(), e); } } }
LibraryFieldUtil { public static int getNativeIntValue(final Class klass, final String fieldName) { try { final Field field = klass.getField(fieldName); return field.getInt(null); } catch (NoSuchFieldException | IllegalAccessException e) { log.error("Failed to get field value for '{}' in {}: {}", fieldName, klass, e.getMessage()); throw new IllegalStateException("Failed to get field value for '" + fieldName + "' from " + klass.getCanonicalName(), e); } } private  LibraryFieldUtil(); }
LibraryFieldUtil { public static int getNativeIntValue(final Class klass, final String fieldName) { try { final Field field = klass.getField(fieldName); return field.getInt(null); } catch (NoSuchFieldException | IllegalAccessException e) { log.error("Failed to get field value for '{}' in {}: {}", fieldName, klass, e.getMessage()); throw new IllegalStateException("Failed to get field value for '" + fieldName + "' from " + klass.getCanonicalName(), e); } } private  LibraryFieldUtil(); static int getNativeIntValue(final Class klass, final String fieldName); static int countClassField(final Class klass); }
LibraryFieldUtil { public static int getNativeIntValue(final Class klass, final String fieldName) { try { final Field field = klass.getField(fieldName); return field.getInt(null); } catch (NoSuchFieldException | IllegalAccessException e) { log.error("Failed to get field value for '{}' in {}: {}", fieldName, klass, e.getMessage()); throw new IllegalStateException("Failed to get field value for '" + fieldName + "' from " + klass.getCanonicalName(), e); } } private  LibraryFieldUtil(); static int getNativeIntValue(final Class klass, final String fieldName); static int countClassField(final Class klass);  }