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

impl.childtrees.MutableChildTreeWithImmutableChilds Maven / Gradle / Ivy

The newest version!
package impl.childtrees;

import api.Node;
import api.Tree;
import exception.TreeInsertionException;
import impl.nodes.ImmutableNode;

/**
 * Created by chief on 04.07.17.
 */
public class MutableChildTreeWithImmutableChilds extends DefaultMutableChildTree {
    public MutableChildTreeWithImmutableChilds(Tree mainTree) {
        super(mainTree);
    }

    @Override
    public void addNode(Node node) throws TreeInsertionException {
        if (!(node instanceof ImmutableNode
                && ((ImmutableNode) node).getChildTree() instanceof MutableChildTreeWithImmutableChilds)){
            throw new IllegalArgumentException(String.format("This child tree only supports Nodes of type %s with child tree of type %s",
                    ImmutableNode.class.getSimpleName(), MutableChildTreeWithImmutableChilds.class.getSimpleName()));
        }
        super.addNode(node);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy