From d3239ea7b6945d449c0361416ab54fec6f9643e6 Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Wed, 11 Nov 2020 12:23:54 -0400 Subject: Update? --- TODO.txt | 5 +++++ src/main/java/bjc/data/Tree.java | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 TODO.txt 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 implements ITree { /* * 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 internalCollapse( @@ -380,6 +377,16 @@ public class Tree implements ITree { return transformer.apply(selectedKid); } + @Override + public ITree 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 transformHead(final Function transformer) { -- cgit v1.2.3