All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cdc.graphs.impl.tests.TestTreeNode Maven / Gradle / Ivy

There is a newer version: 0.71.2
Show newest version
package cdc.graphs.impl.tests;

import cdc.graphs.impl.BasicTree;
import cdc.graphs.impl.BasicTreeNode;

/**
 * Implementation of TreeNode for tests.
 *
 * @author Damien Carbonne
 *
 */
public class TestTreeNode extends BasicTreeNode {
    private String name;
    private static final BasicTree ADAPTER = new BasicTree<>();

    public TestTreeNode() {
        super();
    }

    public TestTreeNode(String name) {
        super();
        setName(name);
    }

    public TestTreeNode(String name,
                        TestTreeNode parent) {
        super();
        setName(name);
        setParent(parent);
    }

    public String getName() {
        return name;
    }

    public final void setName(String name) {
        this.name = name;
    }

    @Override
    public final void setParent(TestTreeNode parent) {
        if (ADAPTER.canSetParent(this, parent)) {
            super.setParent(parent);
        } else {
            throw new IllegalArgumentException("Can not set " + parent + " as parent of " + this);
        }
    }

    @Override
    public String toString() {
        return name;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy