optimize ZkPathConstants
@@ -53,6 +53,8 @@ public final class ZkPathConstants implements Constants {
*/
public static final String META_DATA = PRE_FIX + "/metaData";
+ private static final String SEPARATOR = "/";
+
/**
* acquire app_auth_path.
*
@@ -60,7 +62,7 @@ public final class ZkPathConstants implements Constants {
* @return app_auth_path string
*/
public static String buildAppAuthPath(final String appKey) {
- return String.join("/", APP_AUTH_PARENT, appKey);
+ return String.join(SEPARATOR, APP_AUTH_PARENT, appKey);
}
/**
@@ -70,7 +72,7 @@ public final class ZkPathConstants implements Constants {
* @return the string
*/
public static String buildMetaDataPath(final String path) {
- return META_DATA + "/" + path;
+ return String.join(SEPARATOR, META_DATA, path);
}
/**
@@ -79,7 +81,7 @@ public final class ZkPathConstants implements Constants {
* @return zk path for plugin
*/
public static String buildPluginParentPath() {
- return String.join("/", PLUGIN_PARENT);
+ return String.join(SEPARATOR, PLUGIN_PARENT);
}
/**
@@ -89,7 +91,7 @@ public final class ZkPathConstants implements Constants {
* @return zk path for plugin
*/
public static String buildPluginPath(final String pluginName) {
- return String.join("/", PLUGIN_PARENT, pluginName);
+ return String.join(SEPARATOR, PLUGIN_PARENT, pluginName);
}
/**
@@ -99,7 +101,7 @@ public final class ZkPathConstants implements Constants {
* @return zk path for selector
*/
public static String buildSelectorParentPath(final String pluginName) {
- return String.join("/", SELECTOR_PARENT, pluginName);
+ return String.join(SEPARATOR, SELECTOR_PARENT, pluginName);
}
/**
@@ -110,7 +112,7 @@ public final class ZkPathConstants implements Constants {
* @return zk full path for selector
*/
public static String buildSelectorRealPath(final String pluginName, final String selectorId) {
- return String.join("/", SELECTOR_PARENT, pluginName, selectorId);
+ return String.join(SEPARATOR, SELECTOR_PARENT, pluginName, selectorId);
}
/**
@@ -120,7 +122,7 @@ public final class ZkPathConstants implements Constants {
* @return zk rule parent path.
*/
public static String buildRuleParentPath(final String pluginName) {
- return String.join("/", RULE_PARENT, pluginName);
+ return String.join(SEPARATOR, RULE_PARENT, pluginName);
}
/**
@@ -132,7 +134,7 @@ public final class ZkPathConstants implements Constants {
* @return /soul/rule/pluginName/selectorId-ruleId
*/
public static String buildRulePath(final String pluginName, final String selectorId, final String ruleId) {
- return String.join("/", buildRuleParentPath(pluginName), selectorId + SELECTOR_JOIN_RULE + ruleId);
+ return String.join(SEPARATOR, buildRuleParentPath(pluginName), String.join(SELECTOR_JOIN_RULE, selectorId, ruleId));
}
}
