summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/data
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-11-09 18:53:43 -0500
committerBen Culkin <scorpress@gmail.com>2020-11-09 18:53:43 -0500
commit6340caa7ec15be51c6d633a0519f3e0c76b25241 (patch)
tree1bac6648cae25b7f056eb69856f45d1be13a799b /src/main/java/bjc/data
parentbbddfcafec1b72972e1f925048ddbe715411798d (diff)
Formatting cleanup
Diffstat (limited to 'src/main/java/bjc/data')
-rw-r--r--src/main/java/bjc/data/IPair.java3
-rw-r--r--src/main/java/bjc/data/ITree.java3
-rw-r--r--src/main/java/bjc/data/Identity.java15
-rw-r--r--src/main/java/bjc/data/Lazy.java62
-rw-r--r--src/main/java/bjc/data/LazyPair.java66
-rw-r--r--src/main/java/bjc/data/ListHolder.java15
-rw-r--r--src/main/java/bjc/data/OneWayToggle.java10
-rw-r--r--src/main/java/bjc/data/Option.java28
-rw-r--r--src/main/java/bjc/data/Pair.java41
-rw-r--r--src/main/java/bjc/data/QueuedIterator.java15
-rw-r--r--src/main/java/bjc/data/ResettableIterator.java7
-rw-r--r--src/main/java/bjc/data/TopDownTransformIterator.java18
-rw-r--r--src/main/java/bjc/data/Tree.java43
-rw-r--r--src/main/java/bjc/data/ValueToggle.java14
14 files changed, 142 insertions, 198 deletions
diff --git a/src/main/java/bjc/data/IPair.java b/src/main/java/bjc/data/IPair.java
index 5b1298e..f7d7956 100644
--- a/src/main/java/bjc/data/IPair.java
+++ b/src/main/java/bjc/data/IPair.java
@@ -81,7 +81,8 @@ public interface IPair<LeftType, RightType> extends Bifunctor<LeftType, RightTyp
public default <OtherLeft, OtherRight>
IPair<IPair<LeftType, OtherLeft>, IPair<RightType, OtherRight>>
combine(final IPair<OtherLeft, OtherRight> otherPair) {
- return combine(otherPair, Pair<LeftType, OtherLeft>::new,
+ return combine(otherPair,
+ Pair<LeftType, OtherLeft>::new,
Pair<RightType, OtherRight>::new);
}
diff --git a/src/main/java/bjc/data/ITree.java b/src/main/java/bjc/data/ITree.java
index e9c829e..7f9c67e 100644
--- a/src/main/java/bjc/data/ITree.java
+++ b/src/main/java/bjc/data/ITree.java
@@ -270,8 +270,7 @@ public interface ITree<ContainedType> {
Toggle<Boolean> tog = new OneWayToggle<>(false, true);
traverse(TreeLinearizationMethod.POSTORDER, val -> {
- if (pred.test(val))
- tog.get();
+ if (pred.test(val)) tog.get();
});
return tog.get();
diff --git a/src/main/java/bjc/data/Identity.java b/src/main/java/bjc/data/Identity.java
index c80c7e1..75b4ecd 100644
--- a/src/main/java/bjc/data/Identity.java
+++ b/src/main/java/bjc/data/Identity.java
@@ -48,20 +48,17 @@ public class Identity<ContainedType> implements IHolder<ContainedType> {
@Override
public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof Identity))
- return false;
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Identity)) return false;
final Identity<?> other = (Identity<?>) obj;
if (heldValue == null) {
- if (other.heldValue != null)
- return false;
- } else if (!heldValue.equals(other.heldValue))
+ if (other.heldValue != null) return false;
+ } else if (!heldValue.equals(other.heldValue)) {
return false;
+ }
return true;
}
diff --git a/src/main/java/bjc/data/Lazy.java b/src/main/java/bjc/data/Lazy.java
index a425232..8573325 100644
--- a/src/main/java/bjc/data/Lazy.java
+++ b/src/main/java/bjc/data/Lazy.java
@@ -65,13 +65,14 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> {
bind(final Function<ContainedType, IHolder<BoundType>> binder) {
final IList<UnaryOperator<ContainedType>> pendingActions = new FunctionalList<>();
- actions.forEach(pendingActions::add);
+ for (UnaryOperator<ContainedType> action : actions) {
+ pendingActions.add(action);
+ }
+
final Supplier<ContainedType> supplier = () -> {
- if (valueMaterialized)
- return heldValue;
-
- return valueSupplier.get();
+ if (valueMaterialized) return heldValue;
+ else return valueSupplier.get();
};
return new BoundLazy<>(() -> new Lazy<>(supplier, pendingActions), binder);
@@ -87,8 +88,10 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> {
public <MappedType> IHolder<MappedType>
map(final Function<ContainedType, MappedType> mapper) {
final IList<UnaryOperator<ContainedType>> pendingActions = new FunctionalList<>();
-
- actions.forEach(pendingActions::add);
+
+ for (UnaryOperator<ContainedType> action : actions) {
+ pendingActions.add(action);
+ }
return new Lazy<>(() -> {
ContainedType currVal = heldValue;
@@ -97,7 +100,8 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> {
currVal = valueSupplier.get();
}
- return pendingActions.reduceAux(currVal, UnaryOperator<ContainedType>::apply,
+ return pendingActions.reduceAux(currVal,
+ UnaryOperator<ContainedType>::apply,
value -> mapper.apply(value));
});
}
@@ -107,12 +111,18 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> {
if (valueMaterialized) {
if (actions.isEmpty()) {
return String.format("value[v='%s']", heldValue);
+ } else {
+ return String.format("value[v='%s'] (has %d pending transforms)",
+ heldValue, actions.getSize());
}
-
- return String.format("value[v='%s'] (has pending transforms)", heldValue);
}
- return "(unmaterialized)";
+ if (actions.isEmpty()) {
+ return"(unmaterialized)";
+ } else {
+ return String.format("(unmaterialized; has %d pending transforms",
+ actions.getSize());
+ }
}
@Override
@@ -132,9 +142,9 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> {
valueMaterialized = true;
}
- actions.forEach(action -> {
- heldValue = action.apply(heldValue);
- });
+ for (UnaryOperator<ContainedType> action : actions) {
+ heldValue = action.apply(heldValue);
+ }
actions = new FunctionalList<>();
@@ -155,12 +165,9 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> {
@Override
public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof Lazy<?>))
- return false;
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Lazy<?>)) return false;
final Lazy<?> other = (Lazy<?>) obj;
@@ -169,18 +176,19 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> {
if (valueMaterialized) {
if (heldValue == null) {
- if (other.heldValue != null)
- return false;
- } else if (!heldValue.equals(other.heldValue))
+ if (other.heldValue != null) return false;
+ } else if (!heldValue.equals(other.heldValue)) {
return false;
- } else
+ }
+ } else {
return false;
+ }
if (actions == null) {
- if (other.actions != null)
- return false;
- } else if (actions.getSize() > 0 || other.actions.getSize() > 0)
+ if (other.actions != null) return false;
+ } else if (actions.getSize() > 0 || other.actions.getSize() > 0) {
return false;
+ }
return true;
}
diff --git a/src/main/java/bjc/data/LazyPair.java b/src/main/java/bjc/data/LazyPair.java
index e668cd4..2481cd7 100644
--- a/src/main/java/bjc/data/LazyPair.java
+++ b/src/main/java/bjc/data/LazyPair.java
@@ -79,8 +79,7 @@ public class LazyPair<LeftType, RightType> implements IPair<LeftType, RightType>
public <BoundLeft> IPair<BoundLeft, RightType>
bindLeft(final Function<LeftType, IPair<BoundLeft, RightType>> leftBinder) {
final Supplier<LeftType> leftSupp = () -> {
- if (leftMaterialized)
- return leftValue;
+ if (leftMaterialized) return leftValue;
return leftSupplier.get();
};
@@ -92,8 +91,7 @@ public class LazyPair<LeftType, RightType> implements IPair<LeftType, RightType>
public <BoundRight> IPair<LeftType, BoundRight> bindRight(
final Function<RightType, IPair<LeftType, BoundRight>> rightBinder) {
final Supplier<RightType> rightSupp = () -> {
- if (rightMaterialized)
- return rightValue;
+ if (rightMaterialized) return rightValue;
return rightSupplier.get();
};
@@ -108,12 +106,14 @@ public class LazyPair<LeftType, RightType> implements IPair<LeftType, RightType>
final BiFunction<LeftType, OtherLeft, CombinedLeft> leftCombiner,
final BiFunction<RightType, OtherRight,
CombinedRight> rightCombiner) {
- return otherPair.bind((otherLeft, otherRight) -> bind((leftVal, rightVal) -> {
- final CombinedLeft left = leftCombiner.apply(leftVal, otherLeft);
- final CombinedRight right = rightCombiner.apply(rightVal, otherRight);
-
- return new LazyPair<>(left, right);
- }));
+ return otherPair.bind((otherLeft, otherRight) -> {
+ return bind((leftVal, rightVal) -> {
+ final CombinedLeft left = leftCombiner.apply(leftVal, otherLeft);
+ final CombinedRight right = rightCombiner.apply(rightVal, otherRight);
+
+ return new LazyPair<>(left, right);
+ });
+ });
}
@Override
@@ -142,15 +142,13 @@ public class LazyPair<LeftType, RightType> implements IPair<LeftType, RightType>
public <NewLeft> IPair<NewLeft, RightType>
mapLeft(final Function<LeftType, NewLeft> mapper) {
final Supplier<NewLeft> leftSupp = () -> {
- if (leftMaterialized)
- return mapper.apply(leftValue);
+ if (leftMaterialized) return mapper.apply(leftValue);
return mapper.apply(leftSupplier.get());
};
final Supplier<RightType> rightSupp = () -> {
- if (rightMaterialized)
- return rightValue;
+ if (rightMaterialized) return rightValue;
return rightSupplier.get();
};
@@ -162,15 +160,13 @@ public class LazyPair<LeftType, RightType> implements IPair<LeftType, RightType>
public <NewRight> IPair<LeftType, NewRight>
mapRight(final Function<RightType, NewRight> mapper) {
final Supplier<LeftType> leftSupp = () -> {
- if (leftMaterialized)
- return leftValue;
+ if (leftMaterialized) return leftValue;
return leftSupplier.get();
};
final Supplier<NewRight> rightSupp = () -> {
- if (rightMaterialized)
- return mapper.apply(rightValue);
+ if (rightMaterialized) return mapper.apply(rightValue);
return mapper.apply(rightSupplier.get());
};
@@ -231,37 +227,35 @@ public class LazyPair<LeftType, RightType> implements IPair<LeftType, RightType>
@Override
public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof LazyPair<?, ?>))
- return false;
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof LazyPair<?, ?>)) return false;
final LazyPair<?, ?> other = (LazyPair<?, ?>) obj;
- if (leftMaterialized != other.leftMaterialized)
- return false;
+ if (leftMaterialized != other.leftMaterialized) return false;
if (leftMaterialized) {
if (leftValue == null) {
- if (other.leftValue != null)
- return false;
- } else if (!leftValue.equals(other.leftValue))
+ if (other.leftValue != null) return false;
+ } else if (!leftValue.equals(other.leftValue)) {
return false;
- } else
+ }
+ } else {
return false;
+ }
- if (rightMaterialized != other.rightMaterialized)
- return false;
+ if (rightMaterialized != other.rightMaterialized) return false;
+
if (rightMaterialized) {
if (rightValue == null) {
- if (other.rightValue != null)
- return false;
- } else if (!rightValue.equals(other.rightValue))
+ if (other.rightValue != null) return false;
+ } else if (!rightValue.equals(other.rightValue)) {
return false;
- } else
+ }
+ } else {
return false;
+ }
return true;
}
diff --git a/src/main/java/bjc/data/ListHolder.java b/src/main/java/bjc/data/ListHolder.java
index ab3bfa8..79c900d 100644
--- a/src/main/java/bjc/data/ListHolder.java
+++ b/src/main/java/bjc/data/ListHolder.java
@@ -93,20 +93,17 @@ public class ListHolder<ContainedType> implements IHolder<ContainedType> {
@Override
public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof ListHolder<?>))
- return false;
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof ListHolder<?>)) return false;
final ListHolder<?> other = (ListHolder<?>) obj;
if (heldValues == null) {
- if (other.heldValues != null)
- return false;
- } else if (!heldValues.equals(other.heldValues))
+ if (other.heldValues != null) return false;
+ } else if (!heldValues.equals(other.heldValues)) {
return false;
+ }
return true;
}
diff --git a/src/main/java/bjc/data/OneWayToggle.java b/src/main/java/bjc/data/OneWayToggle.java
index c2e9e4b..b6074b0 100644
--- a/src/main/java/bjc/data/OneWayToggle.java
+++ b/src/main/java/bjc/data/OneWayToggle.java
@@ -31,23 +31,21 @@ public class OneWayToggle<E> implements Toggle<E> {
@Override
public E get() {
- if (gotFirst)
- return second;
+ if (gotFirst) return second;
gotFirst = true;
+
return first;
}
@Override
public E peek() {
- if (gotFirst)
- return second;
- return first;
+ if (gotFirst) return second;
+ else return first;
}
@Override
public void set(boolean gotFirst) {
this.gotFirst = gotFirst;
}
-
}
diff --git a/src/main/java/bjc/data/Option.java b/src/main/java/bjc/data/Option.java
index b5d6d5e..84e71a2 100644
--- a/src/main/java/bjc/data/Option.java
+++ b/src/main/java/bjc/data/Option.java
@@ -27,8 +27,7 @@ public class Option<ContainedType> implements IHolder<ContainedType> {
@Override
public <BoundType> IHolder<BoundType>
bind(final Function<ContainedType, IHolder<BoundType>> binder) {
- if (held == null)
- return new Option<>(null);
+ if (held == null) return new Option<>(null);
return binder.apply(held);
}
@@ -42,8 +41,7 @@ public class Option<ContainedType> implements IHolder<ContainedType> {
@Override
public <MappedType> IHolder<MappedType>
map(final Function<ContainedType, MappedType> mapper) {
- if (held == null)
- return new Option<>(null);
+ if (held == null) return new Option<>(null);
return new Option<>(mapper.apply(held));
}
@@ -51,9 +49,7 @@ public class Option<ContainedType> implements IHolder<ContainedType> {
@Override
public IHolder<ContainedType>
transform(final UnaryOperator<ContainedType> transformer) {
- if (held != null) {
- held = transformer.apply(held);
- }
+ if (held != null) held = transformer.apply(held);
return this;
}
@@ -61,8 +57,7 @@ public class Option<ContainedType> implements IHolder<ContainedType> {
@Override
public <UnwrappedType> UnwrappedType
unwrap(final Function<ContainedType, UnwrappedType> unwrapper) {
- if (held == null)
- return null;
+ if (held == null) return null;
return unwrapper.apply(held);
}
@@ -84,20 +79,17 @@ public class Option<ContainedType> implements IHolder<ContainedType> {
@Override
public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof Option<?>))
- return false;
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Option<?>)) return false;
final Option<?> other = (Option<?>) obj;
if (held == null) {
- if (other.held != null)
- return false;
- } else if (!held.equals(other.held))
+ if (other.held != null) return false;
+ } else if (!held.equals(other.held)) {
return false;
+ }
return true;
}
diff --git a/src/main/java/bjc/data/Pair.java b/src/main/java/bjc/data/Pair.java
index 610e89c..ea2f82f 100644
--- a/src/main/java/bjc/data/Pair.java
+++ b/src/main/java/bjc/data/Pair.java
@@ -22,7 +22,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> {
/** Create a new pair with both sides set to null. */
public Pair() {
-
+ // Do nothing :)
}
/**
@@ -42,8 +42,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> {
@Override
public <BoundLeft, BoundRight> IPair<BoundLeft, BoundRight> bind(
final BiFunction<LeftType, RightType, IPair<BoundLeft, BoundRight>> binder) {
- if (binder == null)
- throw new NullPointerException("Binder must not be null.");
+ if (binder == null) throw new NullPointerException("Binder must not be null.");
return binder.apply(leftValue, rightValue);
}
@@ -51,8 +50,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> {
@Override
public <BoundLeft> IPair<BoundLeft, RightType>
bindLeft(final Function<LeftType, IPair<BoundLeft, RightType>> leftBinder) {
- if (leftBinder == null)
- throw new NullPointerException("Binder must not be null");
+ if (leftBinder == null) throw new NullPointerException("Binder must not be null");
return leftBinder.apply(leftValue);
}
@@ -60,8 +58,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> {
@Override
public <BoundRight> IPair<LeftType, BoundRight> bindRight(
final Function<RightType, IPair<LeftType, BoundRight>> rightBinder) {
- if (rightBinder == null)
- throw new NullPointerException("Binder must not be null");
+ if (rightBinder == null) throw new NullPointerException("Binder must not be null");
return rightBinder.apply(rightValue);
}
@@ -84,8 +81,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> {
@Override
public <NewLeft> IPair<NewLeft, RightType>
mapLeft(final Function<LeftType, NewLeft> mapper) {
- if (mapper == null)
- throw new NullPointerException("Mapper must not be null");
+ if (mapper == null) throw new NullPointerException("Mapper must not be null");
return new Pair<>(mapper.apply(leftValue), rightValue);
}
@@ -93,8 +89,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> {
@Override
public <NewRight> IPair<LeftType, NewRight>
mapRight(final Function<RightType, NewRight> mapper) {
- if (mapper == null)
- throw new NullPointerException("Mapper must not be null");
+ if (mapper == null) throw new NullPointerException("Mapper must not be null");
return new Pair<>(leftValue, mapper.apply(rightValue));
}
@@ -102,8 +97,7 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> {
@Override
public <MergedType> MergedType
merge(final BiFunction<LeftType, RightType, MergedType> merger) {
- if (merger == null)
- throw new NullPointerException("Merger must not be null");
+ if (merger == null) throw new NullPointerException("Merger must not be null");
return merger.apply(leftValue, rightValue);
}
@@ -137,26 +131,23 @@ public class Pair<LeftType, RightType> implements IPair<LeftType, RightType> {
@Override
public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (!(obj instanceof Pair<?, ?>))
- return false;
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (!(obj instanceof Pair<?, ?>)) return false;
final Pair<?, ?> other = (Pair<?, ?>) obj;
if (leftValue == null) {
- if (other.leftValue != null)
- return false;
- } else if (!leftValue.equals(other.leftValue))
+ if (other.leftValue != null) return false;
+ } else if (!leftValue.equals(other.leftValue)) {
return false;
+ }
if (rightValue == null) {
- if (other.rightValue != null)
- return false;
- } else if (!rightValue.equals(other.rightValue))
+ if (other.rightValue != null) return false;
+ } else if (!rightValue.equals(other.rightValue)) {
return false;
+ }
return true;
}
diff --git a/src/main/java/bjc/data/QueuedIterator.java b/src/main/java/bjc/data/QueuedIterator.java
index f10014e..78f180d 100644
--- a/src/main/java/bjc/data/QueuedIterator.java
+++ b/src/main/java/bjc/data/QueuedIterator.java
@@ -82,9 +82,7 @@ public class QueuedIterator<E> implements Iterator<E> {
public QueuedIterator(Iterator<E>... inits) {
this();
- for (Iterator<E> init : inits) {
- pending.add(init);
- }
+ for (Iterator<E> init : inits) pending.add(init);
}
/**
@@ -97,9 +95,7 @@ public class QueuedIterator<E> implements Iterator<E> {
public QueuedIterator(Iterable<E>... inits) {
this();
- for (Iterable<E> init : inits) {
- pending.add(init.iterator());
- }
+ for (Iterable<E> init : inits) pending.add(init.iterator());
}
/**
@@ -208,8 +204,7 @@ public class QueuedIterator<E> implements Iterator<E> {
@Override
public boolean hasNext() {
while (cur == null || !cur.hasNext()) {
- if (pending.isEmpty())
- return false;
+ if (pending.isEmpty()) return false;
cur = pending.pop();
}
@@ -220,13 +215,11 @@ public class QueuedIterator<E> implements Iterator<E> {
@Override
public E next() {
while (cur == null || !cur.hasNext()) {
- if (pending.isEmpty())
- return null;
+ if (pending.isEmpty()) return null;
cur = pending.pop();
}
return cur.next();
}
-
}
diff --git a/src/main/java/bjc/data/ResettableIterator.java b/src/main/java/bjc/data/ResettableIterator.java
index 2208fb2..8b7f07a 100644
--- a/src/main/java/bjc/data/ResettableIterator.java
+++ b/src/main/java/bjc/data/ResettableIterator.java
@@ -56,11 +56,8 @@ public class ResettableIterator<T> implements Iterator<T> {
@Override
public boolean hasNext() {
- if (isRepeating) {
- return cacheIterator.hasNext() ? true : backing.hasNext();
- } else {
- return backing.hasNext();
- }
+ if (isRepeating) return cacheIterator.hasNext() ? true : backing.hasNext();
+ else return backing.hasNext();
}
@Override
diff --git a/src/main/java/bjc/data/TopDownTransformIterator.java b/src/main/java/bjc/data/TopDownTransformIterator.java
index 3b4b997..cf211d3 100644
--- a/src/main/java/bjc/data/TopDownTransformIterator.java
+++ b/src/main/java/bjc/data/TopDownTransformIterator.java
@@ -97,9 +97,7 @@ public class TopDownTransformIterator<ContainedType>
* The nodes to yield.
*/
public void addYield(final Iterator<ITree<ContainedType>> src) {
- if (currYield != null) {
- toYield.push(currYield);
- }
+ if (currYield != null) toYield.push(currYield);
currYield = src;
}
@@ -128,9 +126,7 @@ public class TopDownTransformIterator<ContainedType>
*/
toYield.add(new SingleIterator<>(val));
- if (currYield.hasNext()) {
- return currYield.next();
- }
+ if (currYield.hasNext()) return currYield.next();
while (toYield.size() != 0 && !currYield.hasNext()) {
currYield = toYield.pop();
@@ -149,8 +145,7 @@ public class TopDownTransformIterator<ContainedType>
@Override
public ITree<ContainedType> next() {
- if (done)
- throw new NoSuchElementException();
+ if (done) throw new NoSuchElementException();
/*
* Flush any values that need to be yielded.
@@ -158,8 +153,7 @@ public class TopDownTransformIterator<ContainedType>
if (currYield != null) {
ITree<ContainedType> yeld = flushYields(null);
- if (yeld != null)
- return yeld;
+ if (yeld != null) return yeld;
}
if (initial) {
@@ -226,9 +220,7 @@ public class TopDownTransformIterator<ContainedType>
throw new IllegalArgumentException("Unknown result type " + res);
}
- if (res != RTRANSFORM) {
- initial = false;
- }
+ if (res != RTRANSFORM) initial = false;
}
if (curChild == null || !curChild.hasNext()) {
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;
}
diff --git a/src/main/java/bjc/data/ValueToggle.java b/src/main/java/bjc/data/ValueToggle.java
index 041a2d5..9e4b83b 100644
--- a/src/main/java/bjc/data/ValueToggle.java
+++ b/src/main/java/bjc/data/ValueToggle.java
@@ -37,20 +37,14 @@ public class ValueToggle<E> implements Toggle<E> {
@Override
public E get() {
- if (alignment.get()) {
- return lft;
- }
-
- return rght;
+ if (alignment.get()) return lft;
+ else return rght;
}
@Override
public E peek() {
- if (alignment.peek()) {
- return lft;
- }
-
- return rght;
+ if (alignment.peek()) return lft;
+ else return rght;
}
@Override