diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2020-11-11 12:23:54 -0400 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2020-11-11 12:23:54 -0400 |
| commit | d3239ea7b6945d449c0361416ab54fec6f9643e6 (patch) | |
| tree | 4d85a297a42a355b4dc3f01c677aa02b0d94807b | |
| parent | 3460b2c0c571a61068f664adc5a1b97f6a24cdcc (diff) | |
Update?
| -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); |
