davidsusu / tree-printer

Java library for visualizing tree structures in the command line
Apache License 2.0
39 stars 8 forks source link

Run example code throws NullPointerException #3

Closed morningman closed 3 years ago

morningman commented 3 years ago
    public static void main(String[] args) throws Exception {
        SimpleTreeNode rootNode = new SimpleTreeNode("I'm the root!");
        rootNode.addChild(new SimpleTreeNode("I'm a child..."));
        rootNode.addChild(new SimpleTreeNode("I'm an other child..."));
        new TraditionalTreePrinter().print(new BorderTreeNodeDecorator(rootNode));
    }

Throws:

Exception in thread "main" java.lang.NullPointerException
    at org.apache.doris.common.treeprinter.TraditionalTreePrinter$DefaultAligner.alignChildren(TraditionalTreePrinter.java:266)
    at org.apache.doris.common.treeprinter.TraditionalTreePrinter.print(TraditionalTreePrinter.java:74)
    at org.apache.doris.common.treeprinter.AbstractTreePrinter.print(AbstractTreePrinter.java:28)
    at cmy.MyTest.main(MyTest.java:43)

The package name is changing to org.apache.doris.common.treeprinter because I need to debug the code in my project.

This is because the AbstractTreeNode class missing equals and hashCode method. I will submit a PR to fix this.

davidsusu commented 3 years ago

Thank you for your contribution. I will publish it to the maven central soon.