From f51f6da7319787348c38b875652b5c0e9f88c8aa Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Mon, 13 Apr 2020 18:43:13 -0400 Subject: Cleanup pass Pass to do some cleanups --- .../bjc/funcdata/bst/BinarySearchTreeLeaf.java | 43 ++++++++++++++-------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'src/main/java/bjc/funcdata/bst/BinarySearchTreeLeaf.java') diff --git a/src/main/java/bjc/funcdata/bst/BinarySearchTreeLeaf.java b/src/main/java/bjc/funcdata/bst/BinarySearchTreeLeaf.java index dfad3d9..0b99cad 100644 --- a/src/main/java/bjc/funcdata/bst/BinarySearchTreeLeaf.java +++ b/src/main/java/bjc/funcdata/bst/BinarySearchTreeLeaf.java @@ -11,7 +11,7 @@ import java.util.function.Predicate; * @author ben * * @param - * The data stored in the tree. + * The data stored in the tree. */ public class BinarySearchTreeLeaf implements ITreePart { /** The data held in this tree leaf */ @@ -24,7 +24,7 @@ public class BinarySearchTreeLeaf implements ITreePart { * Create a new leaf holding the specified data. * * @param element - * The data for the leaf to hold. + * The data for the leaf to hold. */ public BinarySearchTreeLeaf(final T element) { data = element; @@ -36,8 +36,10 @@ public class BinarySearchTreeLeaf implements ITreePart { } @Override - public E collapse(final Function leafTransformer, final BiFunction branchCollapser) { - if(leafTransformer == null) throw new NullPointerException("Transformer must not be null"); + public E collapse(final Function leafTransformer, + final BiFunction branchCollapser) { + if (leafTransformer == null) + throw new NullPointerException("Transformer must not be null"); return leafTransformer.apply(data); } @@ -54,16 +56,17 @@ public class BinarySearchTreeLeaf implements ITreePart { @Override public void delete(final T element, final Comparator comparator) { - if(data.equals(element)) { + if (data.equals(element)) { isDeleted = true; } } @Override public boolean directedWalk(final DirectedWalkFunction treeWalker) { - if(treeWalker == null) throw new NullPointerException("Tree walker must not be null"); + if (treeWalker == null) + throw new NullPointerException("Tree walker must not be null"); - switch(treeWalker.walk(data)) { + switch (treeWalker.walk(data)) { case SUCCESS: return true; /* We don't have any children to care about. */ @@ -78,14 +81,16 @@ public class BinarySearchTreeLeaf implements ITreePart { @Override public boolean forEach(final TreeLinearizationMethod linearizationMethod, final Predicate traversalPredicate) { - if(traversalPredicate == null) throw new NullPointerException("Predicate must not be null"); + if (traversalPredicate == null) + throw new NullPointerException("Predicate must not be null"); return traversalPredicate.test(data); } @Override public String toString() { - return String.format("BinarySearchTreeLeaf [data='%s', isDeleted=%s]", data, isDeleted); + return String.format("BinarySearchTreeLeaf [data='%s', isDeleted=%s]", data, + isDeleted); } @Override @@ -99,16 +104,22 @@ public class BinarySearchTreeLeaf implements ITreePart { @Override public boolean equals(final Object obj) { - if(this == obj) return true; - if(obj == null) return false; - if(!(obj instanceof BinarySearchTreeLeaf)) return false; + if (this == obj) + return true; + if (obj == null) + return false; + if (!(obj instanceof BinarySearchTreeLeaf)) + return false; final BinarySearchTreeLeaf other = (BinarySearchTreeLeaf) obj; - if(data == null) { - if(other.data != null) return false; - } else if(!data.equals(other.data)) return false; - if(isDeleted != other.isDeleted) return false; + if (data == null) { + if (other.data != null) + return false; + } else if (!data.equals(other.data)) + return false; + if (isDeleted != other.isDeleted) + return false; return true; } -- cgit v1.2.3