Unverified Commit 3f365ffd authored by 张亮's avatar 张亮 Committed by GitHub
Browse files

Merge pull request #1108 from saaavsaaa/dev

use lombok getter
parents 9b3fa4dd 050861f6
Loading
Loading
Loading
Loading
+4 −20
Original line number Diff line number Diff line
@@ -34,8 +34,10 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public final class PathNode {
    
    @Getter
    private final Map<String, PathNode> children = new ConcurrentHashMap<>();

    @Getter
    private final String nodeKey;
    
    @Getter(value = AccessLevel.PACKAGE)
@@ -56,32 +58,14 @@ public final class PathNode {
        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.
     *
     * @param node node
     */
    public void attachChild(final PathNode node) {
    void attachChild(final PathNode 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) {
+4 −4
Original line number Diff line number Diff line
@@ -92,8 +92,8 @@ public final class PathTree {
                log.debug("loading status:{}", status);
                status = PathStatus.CHANGING;
    
                final PathNode newRoot = new PathNode(rootNode.get().getKey());
                final List<String> children = provider.getChildren(PathUtil.checkPath(rootNode.get().getKey()));
                final PathNode newRoot = new PathNode(rootNode.get().getNodeKey());
                final List<String> children = provider.getChildren(PathUtil.checkPath(rootNode.get().getNodeKey()));
                children.remove(ZookeeperConstants.CHANGING_KEY);
                attachIntoNode(children, newRoot);
                rootNode.set(newRoot);
@@ -190,7 +190,7 @@ public final class PathTree {
     * Watch data change.
     */
    public void watch() {
        watch(new ZookeeperEventListener(rootNode.get().getKey()) {
        watch(new ZookeeperEventListener(rootNode.get().getNodeKey()) {
            @Override
            public void process(final WatchedEvent event) {
                String path = event.getPath();
@@ -222,7 +222,7 @@ public final class PathTree {
        }
        final String key = zookeeperEventListener.getKey();
        log.debug("PathTree Watch:{}", key);
        client.registerWatch(rootNode.get().getKey(), zookeeperEventListener);
        client.registerWatch(rootNode.get().getNodeKey(), zookeeperEventListener);
        watcherKeys.add(key);
    }