
impl.nodes.ImmutableNode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flexible-tree Show documentation
Show all versions of flexible-tree Show documentation
Library for generating permutation of given value domains
The newest version!
package impl.nodes;
import api.ChildTree;
import api.Node;
import api.TreeValue;
import api.utils.NodePath;
import impl.nodepaths.ImmutableNodePath;
import javax.swing.tree.TreeNode;
/**
* Implements a node which value can not be changed
*/
public class ImmutableNode implements Node {
private final TreeValue value;
private final Node parent;
private final ChildTree childTree;
private final NodePath nodePath;
public ImmutableNode(TreeValue value, ChildTree childTree, NodePath nodePath) {
assert childTree != null;
assert value != null;
assert nodePath != null;
this.value = value;
this.childTree = childTree;
this.childTree.setParent(this);
this.parent = null;
this.nodePath = nodePath;
}
public ImmutableNode(TreeValue value, Node parent, ChildTree childTree, NodePath nodePath) {
assert childTree != null;
assert value != null;
assert parent != null;
assert nodePath != null;
this.value = value;
this.childTree = childTree;
this.childTree.setParent(this);
this.parent = parent;
this.nodePath = nodePath;
}
@Override
public TreeValue getValue() {
return value;
}
@Override
public ChildTree getChildTree() {
return childTree;
}
@Override
public NodePath getNodePath() {
return new ImmutableNodePath<>(nodePath.getNodes());
}
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object o) {
return isEqual(o);
}
@Override
public int hashCode() {
return getHashCode();
}
@Override
public TreeNode getParent() {
return parent;
}
@Override
public String toString() {
return "ImmutableNode{" +
"value=" + value +
'}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy