diff --git a/src/main/java/net/kemitix/node/NodeItem.java b/src/main/java/net/kemitix/node/NodeItem.java index f9ebf47..12a7cef 100644 --- a/src/main/java/net/kemitix/node/NodeItem.java +++ b/src/main/java/net/kemitix/node/NodeItem.java @@ -8,7 +8,6 @@ import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.function.Function; /** * Represents a tree of nodes. @@ -23,8 +22,6 @@ class NodeItem implements Node { private final Set> children = new HashSet<>(); - private Function, String> nameSupplier; - private Node parent; private String name; @@ -47,7 +44,6 @@ class NodeItem implements Node { */ NodeItem(final T data) { this.data = data; - this.nameSupplier = (n) -> null; } /** @@ -74,24 +70,8 @@ class NodeItem implements Node { setParent(parent); } - private String generateName() { - return getNameSupplier().apply(this); - } - - private Function, String> getNameSupplier() { - if (nameSupplier != null) { - return nameSupplier; - } - // no test for parent as root nodes will always have a default name - // supplier - return ((NodeItem) parent).getNameSupplier(); - } - @Override public String getName() { - if (name == null) { - return generateName(); - } return name; } @@ -380,14 +360,8 @@ class NodeItem implements Node { public void removeParent() { if (parent != null) { Node oldParent = parent; - Function, String> supplier = getNameSupplier(); parent = null; oldParent.removeChild(this); - if (this.nameSupplier == null) { - // this is now a root node, so must provide a default name - // supplier - this.nameSupplier = supplier; - } } }