diff options
| author | Ben Culkin <scorpress@gmail.com> | 2020-11-09 18:53:43 -0500 |
|---|---|---|
| committer | Ben Culkin <scorpress@gmail.com> | 2020-11-09 18:53:43 -0500 |
| commit | 6340caa7ec15be51c6d633a0519f3e0c76b25241 (patch) | |
| tree | 1bac6648cae25b7f056eb69856f45d1be13a799b /src/main/java/bjc/data/Tree.java | |
| parent | bbddfcafec1b72972e1f925048ddbe715411798d (diff) | |
Formatting cleanup
Diffstat (limited to 'src/main/java/bjc/data/Tree.java')
| -rw-r--r-- | src/main/java/bjc/data/Tree.java | 43 |
1 files changed, 17 insertions, 26 deletions
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<ContainedType> implements ITree<ContainedType> { @Override public void doForChildren(final Consumer<ITree<ContainedType>> action) { - if (childCount > 0) { - children.forEach(action); - } + if (childCount > 0) children.forEach(action); } @Override @@ -151,13 +149,10 @@ public class Tree<ContainedType> implements ITree<ContainedType> { @Override public int revFind(final Predicate<ITree<ContainedType>> 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<ContainedType> implements ITree<ContainedType> { 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<ContainedType> implements ITree<ContainedType> { final Function<ContainedType, MappedType> leafTransformer, final Function<ContainedType, MappedType> operatorTransformer) { if (hasChildren) { - final IList<ITree<MappedType>> mappedChildren = children.map(child -> child.rebuildTree(leafTransformer, operatorTransformer)); + final IList<ITree<MappedType>> 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<ContainedType> implements ITree<ContainedType> { @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; } |
