@Test public void getProperty() { String a = PropertyHolder.getProperty("test.str.str2"); Assert.equals(a, "bcd", ErrorCodeDef.SYSTEM_ERROR_10001); a = PropertyHolder.getProperty("test.str.none", "abcdefg"); Assert.equals(a, "abcdefg", ErrorCodeDef.SYSTEM_ERROR_10001); a = PropertyHolder.getProperty("test.int.int2"); Assert.equals(a, "-1", ErrorCodeDef.SYSTEM_ERROR_10001); a = PropertyHolder.getProperty("test.long.long2"); Assert.equals(a, "3000", ErrorCodeDef.SYSTEM_ERROR_10001); a = PropertyHolder.getProperty("test.bool.bool2"); Assert.equals(a, "false", ErrorCodeDef.SYSTEM_ERROR_10001); }
public static String getProperty(final String name) { String value = PROPERTIES.get(name); if (org.apache.commons.lang3.StringUtils.isNotEmpty(value)) { int startIndex = value.indexOf("${"); if (startIndex != -1) { String key = value.substring(startIndex + 2, value.indexOf("}", startIndex + 2)); if (!org.apache.commons.lang3.StringUtils.equals(name, key) && org.apache.commons.lang3.StringUtils.isNotEmpty(key)) { String kv = getProperty(key); value = StringUtils.replace(value, "${" + key + "}", kv); } } } return value; }
PropertyHolder { public static String getProperty(final String name) { String value = PROPERTIES.get(name); if (org.apache.commons.lang3.StringUtils.isNotEmpty(value)) { int startIndex = value.indexOf("${"); if (startIndex != -1) { String key = value.substring(startIndex + 2, value.indexOf("}", startIndex + 2)); if (!org.apache.commons.lang3.StringUtils.equals(name, key) && org.apache.commons.lang3.StringUtils.isNotEmpty(key)) { String kv = getProperty(key); value = StringUtils.replace(value, "${" + key + "}", kv); } } } return value; } }
PropertyHolder { public static String getProperty(final String name) { String value = PROPERTIES.get(name); if (org.apache.commons.lang3.StringUtils.isNotEmpty(value)) { int startIndex = value.indexOf("${"); if (startIndex != -1) { String key = value.substring(startIndex + 2, value.indexOf("}", startIndex + 2)); if (!org.apache.commons.lang3.StringUtils.equals(name, key) && org.apache.commons.lang3.StringUtils.isNotEmpty(key)) { String kv = getProperty(key); value = StringUtils.replace(value, "${" + key + "}", kv); } } } return value; }  }
PropertyHolder { public static String getProperty(final String name) { String value = PROPERTIES.get(name); if (org.apache.commons.lang3.StringUtils.isNotEmpty(value)) { int startIndex = value.indexOf("${"); if (startIndex != -1) { String key = value.substring(startIndex + 2, value.indexOf("}", startIndex + 2)); if (!org.apache.commons.lang3.StringUtils.equals(name, key) && org.apache.commons.lang3.StringUtils.isNotEmpty(key)) { String kv = getProperty(key); value = StringUtils.replace(value, "${" + key + "}", kv); } } } return value; }  static Map<String, String> getProperties(); static Boolean getBooleanProperty(final String name); static Boolean getBooleanProperty(final String name, final Boolean defaultValue); static Integer getIntProperty(final String name); static Integer getIntProperty(final String name, final Integer defaultValue); static Long getLongProperty(final String name); static Long getLongProperty(final String name, final Long defaultValue); static String getProperty(final String name); static String getProperty(final String name, final String defaultValue); static void setProperty(final String name, final String value); static String getErrorMessage(final int code, final Object... params); static String getProjectName(); static String getVersion(); }
PropertyHolder { public static String getProperty(final String name) { String value = PROPERTIES.get(name); if (org.apache.commons.lang3.StringUtils.isNotEmpty(value)) { int startIndex = value.indexOf("${"); if (startIndex != -1) { String key = value.substring(startIndex + 2, value.indexOf("}", startIndex + 2)); if (!org.apache.commons.lang3.StringUtils.equals(name, key) && org.apache.commons.lang3.StringUtils.isNotEmpty(key)) { String kv = getProperty(key); value = StringUtils.replace(value, "${" + key + "}", kv); } } } return value; }  static Map<String, String> getProperties(); static Boolean getBooleanProperty(final String name); static Boolean getBooleanProperty(final String name, final Boolean defaultValue); static Integer getIntProperty(final String name); static Integer getIntProperty(final String name, final Integer defaultValue); static Long getLongProperty(final String name); static Long getLongProperty(final String name, final Long defaultValue); static String getProperty(final String name); static String getProperty(final String name, final String defaultValue); static void setProperty(final String name, final String value); static String getErrorMessage(final int code, final Object... params); static String getProjectName(); static String getVersion();  }