From 6340caa7ec15be51c6d633a0519f3e0c76b25241 Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Mon, 9 Nov 2020 18:53:43 -0500 Subject: Formatting cleanup --- src/main/java/bjc/data/Tree.java | 43 ++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 26 deletions(-) (limited to 'src/main/java/bjc/data/Tree.java') diff --git a/src/main/java/bjc/data/Tree.java b/src/main/java/bjc/data/Tree.java index 9a4caa6..95f4d1e 100644 --- a/src/main/java/bjc/data/Tree.java +++ b/src/main/java/bjc/data/Tree.java @@ -139,9 +139,7 @@ public class Tree implements ITree { @Override public void doForChildren(final Consumer> action) { - if (childCount > 0) { - children.forEach(action); - } + if (childCount > 0) children.forEach(action); } @Override @@ -151,13 +149,10 @@ public class Tree implements ITree { @Override public int revFind(final Predicate> childPred) { - if (childCount == 0) { - return -1; - } + if (childCount == 0) return -1; for (int i = childCount - 1; i >= 0; i--) { - if (childPred.test(getChild(i))) - return i; + if (childPred.test(getChild(i))) return i; } return -1; @@ -252,9 +247,7 @@ public class Tree implements ITree { private void internalToString(final StringBuilder builder, final int indentLevel, final boolean initial) { if (!initial) { - for (int i = 0; i < indentLevel; i++) { - builder.append(">\t"); - } + for (int i = 0; i < indentLevel; i++) builder.append(">\t"); } builder.append("Node #"); @@ -287,7 +280,9 @@ public class Tree implements ITree { final Function leafTransformer, final Function operatorTransformer) { if (hasChildren) { - final IList> mappedChildren = children.map(child -> child.rebuildTree(leafTransformer, operatorTransformer)); + final IList> mappedChildren = + children.map(child -> + child.rebuildTree(leafTransformer, operatorTransformer)); final MappedType mapData = operatorTransformer.apply(data); return new Tree<>(mapData, mappedChildren); @@ -417,29 +412,25 @@ public class Tree implements ITree { @Override public boolean equals(final Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof Tree)) - return false; + if (this == obj) return true; + if (obj == null) return false; + if (!(obj instanceof Tree)) return false; final Tree other = (Tree) obj; if (data == null) { - if (other.data != null) - return false; - } else if (!data.equals(other.data)) + if (other.data != null) return false; + } else if (!data.equals(other.data)) { return false; + } - if (childCount != other.childCount) - return false; + if (childCount != other.childCount) return false; if (children == null) { - if (other.children != null) - return false; - } else if (!children.equals(other.children)) + if (other.children != null) return false; + } else if (!children.equals(other.children)) { return false; + } return true; } -- cgit v1.2.3 From c56a10f7c943dd9e9f04854395638babfaba6529 Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Wed, 11 Nov 2020 11:22:42 -0500 Subject: Tweak some things --- src/main/java/bjc/data/Tree.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/main/java/bjc/data/Tree.java') diff --git a/src/main/java/bjc/data/Tree.java b/src/main/java/bjc/data/Tree.java index 95f4d1e..83b33bd 100644 --- a/src/main/java/bjc/data/Tree.java +++ b/src/main/java/bjc/data/Tree.java @@ -28,8 +28,10 @@ public class Tree implements ITree { /* Whether this node has children. */ /* * @NOTE Why have both this boolean and childCount? Why not just do a childCount - * == 0 whenever you'd check hasChildren? - Because hasChildren is set once and - * not reset, and really what it indicates is that children has been allocated. + * == 0 whenever you'd check hasChildren? + * + * - Because hasChildren is set once and not reset, and really what it + * indicates is that children has been allocated. */ private boolean hasChildren; /* The number of children this node has. */ -- cgit v1.2.3