com.neko233.skilltree.game.attributeTree.impl.GameGameAttributeTree Maven / Gradle / Ivy
package com.neko233.skilltree.game.attributeTree.impl;
import com.neko233.skilltree.game.attributeTree.GameAttributeNode;
import com.neko233.skilltree.game.attributeTree.GameAttributeTreeApi;
import java.util.HashMap;
import java.util.Map;
public class GameGameAttributeTree implements GameAttributeTreeApi {
private final Map pathToNodeMap = new HashMap<>();
public GameGameAttributeTree() {
}
@Override
public void addAttribute(GameAttributeNode node) {
String path = node.getPath();
pathToNodeMap.put(path, node);
updateParentNodeRecursive(node, true);
}
@Override
public void removeAttribute(String path) {
GameAttributeNode removeNode = pathToNodeMap.remove(path);
updateParentNodeRecursive(removeNode, false);
}
@Override
public GameAttributeNode getAttributeNode(String path) {
return pathToNodeMap.get(path);
}
@Override
public Map getPathToNodeMap() {
return pathToNodeMap;
}
}