Skip to content

Instantly share code, notes, and snippets.

@claymccoy
Created August 18, 2008 15:04
Show Gist options
  • Save claymccoy/5975 to your computer and use it in GitHub Desktop.
Save claymccoy/5975 to your computer and use it in GitHub Desktop.
public class TreeNode {
private final String name;
private final Collection<TreeNode> children;
public TreeNode(String name) {
this.name = name;
children = new HashSet<TreeNode>();
}
public String getName() {
return this.name;
}
public Collection<TreeNode> getChildren() {
// don't show your privates!
return Collections.unmodifiableCollection(children);
}
public void addChild(final TreeNode treeNode) {
children.add(treeNode);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment