diff options
| -rw-r--r-- | TODO.txt | 5 | ||||
| -rw-r--r-- | src/main/java/bjc/data/Tree.java | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..ee3175d --- /dev/null +++ b/TODO.txt @@ -0,0 +1,5 @@ +@TODO, Oct 17th, 2020 - Ben Culkin - :ExceptionOverview + Go over all of the code and make sure that the exceptions we are throwing + are of the right type, and have a useful message. In some contexts, this may + mean creating some wrapper exception types, just to make it clear what + exactly has gone wrong diff --git a/src/main/java/bjc/data/Tree.java b/src/main/java/bjc/data/Tree.java index 9a4caa6..5337af5 100644 --- a/src/main/java/bjc/data/Tree.java +++ b/src/main/java/bjc/data/Tree.java @@ -227,9 +227,6 @@ public class Tree<ContainedType> implements ITree<ContainedType> { /* * Do a collapse of this tree. - * - * @NOTE Why is this protected? I can't see any good reason someone'd want to - * override it. */ private <NewType> NewType internalCollapse( @@ -381,6 +378,16 @@ public class Tree<ContainedType> implements ITree<ContainedType> { } @Override + public ITree<ContainedType> getChild(final int childNo) { + if (childNo < 0 || childNo > childCount - 1) { + final String msg = String.format("Child index #%d is invalid", childNo); + + throw new IllegalArgumentException(msg); + } + return children.getByIndex(childNo); + } + + @Override public <TransformedType> TransformedType transformHead(final Function<ContainedType, TransformedType> transformer) { return transformer.apply(data); |
