XenonConfiguration { long getInteger(Class<?> subsystem, String property, long defaultValue) { String v = this.source.get(subsystem, property, true); if (v == null) { logUsingDefaultBecauseUnset(subsystem, property, defaultValue, true); return defaultValue; } try { return Long.parseLong(v); } catch (NumberFormatException e) { } if (lastToUpper(v) == 'K') { Long res = parseOr(stripSuffix(v, 1)); if (res == null) { logUsingDefaultBecauseBadValue(subsystem, property, defaultValue, v); return defaultValue; } else { return 1024 * res; } } if (lastToUpper(v) == 'M') { Long res = parseOr(stripSuffix(v, 1)); if (res == null) { logUsingDefaultBecauseBadValue(subsystem, property, defaultValue, v); return defaultValue; } else { return 1024 * 1024 * res; } } if (lastToUpper(v) == 'G') { Long res = parseOr(stripSuffix(v, 1)); if (res == null) { logUsingDefaultBecauseBadValue(subsystem, property, defaultValue, v); return defaultValue; } else { return 1024 * 1024 * 1024 * res; } } logUsingDefaultBecauseBadValue(subsystem, property, defaultValue, v); return defaultValue; } XenonConfiguration(ConfigurationSource source); static double decimal(Class<?> subsystem, String property, double defaultValue); static long number(Class<?> subsystem, String property, long defaultValue); static int integer(Class<?> subsystem, String property, long defaultValue); static long duration(Class<?> subsystem, String property, Duration defaultValue); static long duration(Class<?> subsystem, String property, TimeUnit unit, long duration); static String string(Class<?> subsystem, String property, String defaultValue); static T choice(Class<?> subsystem, String property, Class<T> enumType,
            T defaultValue); static String secret(Class<?> subsystem, String property, String defaultValue); static boolean bool(String subsystem, String property, boolean defaultValue); static boolean bool(Class<?> subsystem, String property, boolean defaultValue);  }
@Test public void integerSuffix() throws Exception { prepareConfig("20K"); assertEquals(20 * 1024, this.config.getInteger(XenonConfigurationTest.class, this.foundProperty, -1)); prepareConfig("20k"); assertEquals(20 * 1024, this.config.getInteger(XenonConfigurationTest.class, this.foundProperty, -1)); prepareConfig("1M"); assertEquals(1 * 1024 * 1024, this.config.getInteger(XenonConfigurationTest.class, this.foundProperty, -1)); prepareConfig("1m"); assertEquals(1 * 1024 * 1024, this.config.getInteger(XenonConfigurationTest.class, this.foundProperty, -1)); prepareConfig("1G"); assertEquals(1 * 1024 * 1024 * 1024, this.config.getInteger(XenonConfigurationTest.class, this.foundProperty, -1)); prepareConfig("1g"); assertEquals(1 * 1024 * 1024 * 1024, this.config.getInteger(XenonConfigurationTest.class, this.foundProperty, -1)); prepareConfig("hundredK"); assertEquals(-1, this.config.getInteger(XenonConfigurationTest.class, this.foundProperty, -1)); }