com.cisco.common.constructs.Node Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of device-package-maven-plugin Show documentation
Show all versions of device-package-maven-plugin Show documentation
Provides support for building Device Package related projects for various Cisco Network Management Products.
The newest version!
/******************************************************************************
* Copyright (c) 2011-2018 by Cisco Systems, Inc. and/or its affiliates.
* All rights reserved.
*
* This software is made available under the CISCO SAMPLE CODE LICENSE
* Version 1.1. See LICENSE.TXT at the root of this project for more information.
*
********************************************************************************/
package com.cisco.common.constructs;
import java.util.ArrayList;
import java.util.Collection;
/**
* Represents a Node in a Tree, allows up/down traversal to both parent items in
* the tree, and child items in the tree.
*
* @author danijoh2
*
* @param
* - The type of data that will be stored in the Node.
*/
public class Node {
private T data;
private Node parent;
private Collection> children;
public Node(T data, Node parent) {
this.data = data;
this.parent = parent;
children = new ArrayList>();
}
public T getData() {
return data;
}
public Node getParent() {
return parent;
}
public Collection> getChildren() {
return children;
}
public boolean hasChildren() {
return children.size() > 0;
}
public Node addChild(T child) {
Node childNode = new Node(child, this);
children.add(childNode);
return childNode;
}
public void addChild(Node child) {
child.parent = this;
children.add(child);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy