@Test public void getValidLongValue() { String key = GlobalConstants.Consumer.Key.BACKOFF_INITIAL; long defaultValue = 1L; Properties properties = SystemConfig.getProperties(); long value = PropertiesUtils.getValidLongValue(properties, key, defaultValue); if (value <= 0) { value = defaultValue; } Assert.assertEquals(defaultValue, value); }
public static long getValidLongValue(Properties properties, String key, long defaultValue) { if (properties == null) { return defaultValue; } long result = defaultValue; if (properties.containsKey(key)) { String value = properties.getProperty(key); if (value != null) { value = value.trim(); } if (MathUtils.isLong(value)) { result = Long.parseLong(value); } } return result; }
PropertiesUtils { public static long getValidLongValue(Properties properties, String key, long defaultValue) { if (properties == null) { return defaultValue; } long result = defaultValue; if (properties.containsKey(key)) { String value = properties.getProperty(key); if (value != null) { value = value.trim(); } if (MathUtils.isLong(value)) { result = Long.parseLong(value); } } return result; } }
PropertiesUtils { public static long getValidLongValue(Properties properties, String key, long defaultValue) { if (properties == null) { return defaultValue; } long result = defaultValue; if (properties.containsKey(key)) { String value = properties.getProperty(key); if (value != null) { value = value.trim(); } if (MathUtils.isLong(value)) { result = Long.parseLong(value); } } return result; }  }
PropertiesUtils { public static long getValidLongValue(Properties properties, String key, long defaultValue) { if (properties == null) { return defaultValue; } long result = defaultValue; if (properties.containsKey(key)) { String value = properties.getProperty(key); if (value != null) { value = value.trim(); } if (MathUtils.isLong(value)) { result = Long.parseLong(value); } } return result; }  static Properties getProperties(String filePath); static int getValidIntegerValue(Properties properties, String key, int defaultValue); static long getValidLongValue(Properties properties, String key, long defaultValue); static double getValidDoubleValue(Properties properties, String key, double defaultValue); static String getStringValue(Properties properties, String key, String defaultValue); static boolean getValidBooleanValue(Properties properties, String key, boolean defaultValue); }
PropertiesUtils { public static long getValidLongValue(Properties properties, String key, long defaultValue) { if (properties == null) { return defaultValue; } long result = defaultValue; if (properties.containsKey(key)) { String value = properties.getProperty(key); if (value != null) { value = value.trim(); } if (MathUtils.isLong(value)) { result = Long.parseLong(value); } } return result; }  static Properties getProperties(String filePath); static int getValidIntegerValue(Properties properties, String key, int defaultValue); static long getValidLongValue(Properties properties, String key, long defaultValue); static double getValidDoubleValue(Properties properties, String key, double defaultValue); static String getStringValue(Properties properties, String key, String defaultValue); static boolean getValidBooleanValue(Properties properties, String key, boolean defaultValue);  }