提交 050861f6 编写于 作者: draculav's avatar draculav

use lombok

上级 3c333447
...@@ -34,8 +34,10 @@ import lombok.extern.slf4j.Slf4j; ...@@ -34,8 +34,10 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
public final class PathNode { public final class PathNode {
@Getter
private final Map<String, PathNode> children = new ConcurrentHashMap<>(); private final Map<String, PathNode> children = new ConcurrentHashMap<>();
@Getter
private final String nodeKey; private final String nodeKey;
@Getter(value = AccessLevel.PACKAGE) @Getter(value = AccessLevel.PACKAGE)
...@@ -56,32 +58,14 @@ public final class PathNode { ...@@ -56,32 +58,14 @@ public final class PathNode {
this.path = key; this.path = key;
} }
/**
* Get children.
*
* @return children
*/
public Map<String, PathNode> getChildren() {
return children;
}
/**
* Get key.
*
* @return node key
*/
public String getKey() {
return this.nodeKey;
}
/** /**
* Attach child node. * Attach child node.
* *
* @param node node * @param node node
*/ */
public void attachChild(final PathNode node) { void attachChild(final PathNode node) {
this.children.put(node.nodeKey, node); this.children.put(node.nodeKey, node);
node.setPath(PathUtil.getRealPath(path, node.getKey())); node.setPath(PathUtil.getRealPath(path, node.getNodeKey()));
} }
PathNode set(final PathResolve pathResolve, final String value) { PathNode set(final PathResolve pathResolve, final String value) {
......
...@@ -92,8 +92,8 @@ public final class PathTree { ...@@ -92,8 +92,8 @@ public final class PathTree {
log.debug("loading status:{}", status); log.debug("loading status:{}", status);
status = PathStatus.CHANGING; status = PathStatus.CHANGING;
final PathNode newRoot = new PathNode(rootNode.get().getKey()); final PathNode newRoot = new PathNode(rootNode.get().getNodeKey());
final List<String> children = provider.getChildren(PathUtil.checkPath(rootNode.get().getKey())); final List<String> children = provider.getChildren(PathUtil.checkPath(rootNode.get().getNodeKey()));
children.remove(ZookeeperConstants.CHANGING_KEY); children.remove(ZookeeperConstants.CHANGING_KEY);
attachIntoNode(children, newRoot); attachIntoNode(children, newRoot);
rootNode.set(newRoot); rootNode.set(newRoot);
...@@ -190,7 +190,7 @@ public final class PathTree { ...@@ -190,7 +190,7 @@ public final class PathTree {
* Watch data change. * Watch data change.
*/ */
public void watch() { public void watch() {
watch(new ZookeeperEventListener(rootNode.get().getKey()) { watch(new ZookeeperEventListener(rootNode.get().getNodeKey()) {
@Override @Override
public void process(final WatchedEvent event) { public void process(final WatchedEvent event) {
String path = event.getPath(); String path = event.getPath();
...@@ -222,7 +222,7 @@ public final class PathTree { ...@@ -222,7 +222,7 @@ public final class PathTree {
} }
final String key = zookeeperEventListener.getKey(); final String key = zookeeperEventListener.getKey();
log.debug("PathTree Watch:{}", key); log.debug("PathTree Watch:{}", key);
client.registerWatch(rootNode.get().getKey(), zookeeperEventListener); client.registerWatch(rootNode.get().getNodeKey(), zookeeperEventListener);
watcherKeys.add(key); watcherKeys.add(key);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册