summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/data/internals
diff options
context:
space:
mode:
Diffstat (limited to 'base/src/main/java/bjc/utils/data/internals')
-rw-r--r--base/src/main/java/bjc/utils/data/internals/BoundLazy.java24
-rw-r--r--base/src/main/java/bjc/utils/data/internals/BoundLazyPair.java49
-rw-r--r--base/src/main/java/bjc/utils/data/internals/BoundListHolder.java15
-rw-r--r--base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java28
-rw-r--r--base/src/main/java/bjc/utils/data/internals/WrappedLazy.java4
-rw-r--r--base/src/main/java/bjc/utils/data/internals/WrappedOption.java10
6 files changed, 65 insertions, 65 deletions
diff --git a/base/src/main/java/bjc/utils/data/internals/BoundLazy.java b/base/src/main/java/bjc/utils/data/internals/BoundLazy.java
index a1c2ea0..f4e8f7e 100644
--- a/base/src/main/java/bjc/utils/data/internals/BoundLazy.java
+++ b/base/src/main/java/bjc/utils/data/internals/BoundLazy.java
@@ -32,13 +32,13 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
private final IList<UnaryOperator<BoundContainedType>> actions = new FunctionalList<>();
/**
- * Create a new bound lazy value.
+ * Create a new bound lazy value.
*
* @param supp
- * The supplier of the old value.
+ * The supplier of the old value.
*
* @param binder
- * The function to use to bind the old value to the new one.
+ * The function to use to bind the old value to the new one.
*/
public BoundLazy(final Supplier<IHolder<OldType>> supp,
final Function<OldType, IHolder<BoundContainedType>> binder) {
@@ -48,7 +48,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
@Override
public <BoundType> IHolder<BoundType> bind(final Function<BoundContainedType, IHolder<BoundType>> bindr) {
- if (bindr == null) throw new NullPointerException("Binder must not be null");
+ if(bindr == null) throw new NullPointerException("Binder must not be null");
/* Prepare a list of pending actions. */
final IList<UnaryOperator<BoundContainedType>> pendingActions = new FunctionalList<>();
@@ -59,7 +59,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
IHolder<BoundContainedType> oldHolder = boundHolder;
/* Bind the value if it hasn't been bound before. */
- if (!holderBound) {
+ if(!holderBound) {
oldHolder = oldSupplier.get().unwrap(binder);
}
@@ -75,7 +75,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
@Override
public <NewType> Function<BoundContainedType, IHolder<NewType>> lift(
final Function<BoundContainedType, NewType> func) {
- if (func == null) throw new NullPointerException("Function to lift must not be null");
+ if(func == null) throw new NullPointerException("Function to lift must not be null");
return (val) -> {
return new Lazy<>(func.apply(val));
@@ -84,7 +84,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
@Override
public <MappedType> IHolder<MappedType> map(final Function<BoundContainedType, MappedType> mapper) {
- if (mapper == null) throw new NullPointerException("Mapper must not be null");
+ if(mapper == null) throw new NullPointerException("Mapper must not be null");
/* Prepare a list of pending actions. */
final IList<UnaryOperator<BoundContainedType>> pendingActions = new FunctionalList<>();
@@ -95,7 +95,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
IHolder<BoundContainedType> oldHolder = boundHolder;
/* Bound the value if it hasn't been bound. */
- if (!holderBound) {
+ if(!holderBound) {
oldHolder = oldSupplier.get().unwrap(binder);
}
@@ -110,14 +110,14 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
@Override
public String toString() {
- if (holderBound) return boundHolder.toString();
+ if(holderBound) return boundHolder.toString();
return "(unmaterialized)";
}
@Override
public IHolder<BoundContainedType> transform(final UnaryOperator<BoundContainedType> transformer) {
- if (transformer == null) throw new NullPointerException("Transformer must not be null");
+ if(transformer == null) throw new NullPointerException("Transformer must not be null");
actions.add(transformer);
@@ -126,9 +126,9 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
@Override
public <UnwrappedType> UnwrappedType unwrap(final Function<BoundContainedType, UnwrappedType> unwrapper) {
- if (unwrapper == null) throw new NullPointerException("Unwrapper must not be null");
+ if(unwrapper == null) throw new NullPointerException("Unwrapper must not be null");
- if (!holderBound) {
+ if(!holderBound) {
boundHolder = oldSupplier.get().unwrap(binder::apply);
}
diff --git a/base/src/main/java/bjc/utils/data/internals/BoundLazyPair.java b/base/src/main/java/bjc/utils/data/internals/BoundLazyPair.java
index 401f5d5..2ef0e4c 100644
--- a/base/src/main/java/bjc/utils/data/internals/BoundLazyPair.java
+++ b/base/src/main/java/bjc/utils/data/internals/BoundLazyPair.java
@@ -34,13 +34,14 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
* Create a new bound lazy pair.
*
* @param leftSupp
- * The supplier for the left value.
+ * The supplier for the left value.
*
* @param rightSupp
- * The supplier for the right value.
+ * The supplier for the right value.
*
* @param bindr
- * The function to use to bind the left and right into a new pair.
+ * The function to use to bind the left and right into a new
+ * pair.
*/
public BoundLazyPair(final Supplier<OldLeft> leftSupp, final Supplier<OldRight> rightSupp,
final BiFunction<OldLeft, OldRight, IPair<NewLeft, NewRight>> bindr) {
@@ -52,13 +53,13 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public <BoundLeft, BoundRight> IPair<BoundLeft, BoundRight> bind(
final BiFunction<NewLeft, NewRight, IPair<BoundLeft, BoundRight>> bindr) {
- if (bindr == null) throw new NullPointerException("Binder must not be null");
+ if(bindr == null) throw new NullPointerException("Binder must not be null");
final IHolder<IPair<NewLeft, NewRight>> newPair = new Identity<>(boundPair);
- final IHolder<Boolean> newPairMade = new Identity<>(pairBound);
+ final IHolder<Boolean> newPairMade = new Identity<>(pairBound);
final Supplier<NewLeft> leftSupp = () -> {
- if (!newPairMade.getValue()) {
+ if(!newPairMade.getValue()) {
/*
* If the pair hasn't been bound before, bind
* it.
@@ -72,7 +73,7 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
};
final Supplier<NewRight> rightSupp = () -> {
- if (!newPairMade.getValue()) {
+ if(!newPairMade.getValue()) {
/*
* If the pair hasn't been bound before, bind
* it.
@@ -91,12 +92,12 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public <BoundLeft> IPair<BoundLeft, NewRight> bindLeft(
final Function<NewLeft, IPair<BoundLeft, NewRight>> leftBinder) {
- if (leftBinder == null) throw new NullPointerException("Left binder must not be null");
+ if(leftBinder == null) throw new NullPointerException("Left binder must not be null");
final Supplier<NewLeft> leftSupp = () -> {
IPair<NewLeft, NewRight> newPair = boundPair;
- if (!pairBound) {
+ if(!pairBound) {
/*
* If the pair hasn't been bound before, bind
* it.
@@ -113,12 +114,12 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public <BoundRight> IPair<NewLeft, BoundRight> bindRight(
final Function<NewRight, IPair<NewLeft, BoundRight>> rightBinder) {
- if (rightBinder == null) throw new NullPointerException("Right binder must not be null");
+ if(rightBinder == null) throw new NullPointerException("Right binder must not be null");
final Supplier<NewRight> rightSupp = () -> {
IPair<NewLeft, NewRight> newPair = boundPair;
- if (!pairBound) {
+ if(!pairBound) {
/*
* If the pair hasn't been bound before, bind
* it.
@@ -137,17 +138,17 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
final IPair<OtherLeft, OtherRight> otherPair,
final BiFunction<NewLeft, OtherLeft, CombinedLeft> leftCombiner,
final BiFunction<NewRight, OtherRight, CombinedRight> rightCombiner) {
- if (otherPair == null) {
+ if(otherPair == null) {
throw new NullPointerException("Other pair must not be null");
- } else if (leftCombiner == null) {
+ } else if(leftCombiner == null) {
throw new NullPointerException("Left combiner must not be null");
- } else if (rightCombiner == null) {
+ } else if(rightCombiner == null) {
throw new NullPointerException("Right combiner must not be null");
}
return otherPair.bind((otherLeft, otherRight) -> {
return bind((leftVal, rightVal) -> {
- CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft);
+ CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft);
CombinedRight cRight = rightCombiner.apply(rightVal, otherRight);
return new LazyPair<>(cLeft, cRight);
@@ -157,10 +158,10 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public <NewLeftType> IPair<NewLeftType, NewRight> mapLeft(final Function<NewLeft, NewLeftType> mapper) {
- if (mapper == null) throw new NullPointerException("Mapper must not be null");
+ if(mapper == null) throw new NullPointerException("Mapper must not be null");
final Supplier<NewLeftType> leftSupp = () -> {
- if (!pairBound) {
+ if(!pairBound) {
final NewLeft leftVal = binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft();
return mapper.apply(leftVal);
@@ -170,7 +171,7 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
};
final Supplier<NewRight> rightSupp = () -> {
- if (!pairBound) return binder.apply(leftSupplier.get(), rightSupplier.get()).getRight();
+ if(!pairBound) return binder.apply(leftSupplier.get(), rightSupplier.get()).getRight();
return boundPair.getRight();
};
@@ -180,16 +181,16 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public <NewRightType> IPair<NewLeft, NewRightType> mapRight(final Function<NewRight, NewRightType> mapper) {
- if (mapper == null) throw new NullPointerException("Mapper must not be null");
+ if(mapper == null) throw new NullPointerException("Mapper must not be null");
final Supplier<NewLeft> leftSupp = () -> {
- if (!pairBound) return binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft();
+ if(!pairBound) return binder.apply(leftSupplier.get(), rightSupplier.get()).getLeft();
return boundPair.getLeft();
};
final Supplier<NewRightType> rightSupp = () -> {
- if (!pairBound) {
+ if(!pairBound) {
final NewRight rightVal = binder.apply(leftSupplier.get(), rightSupplier.get())
.getRight();
@@ -204,9 +205,9 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public <MergedType> MergedType merge(final BiFunction<NewLeft, NewRight, MergedType> merger) {
- if (merger == null) throw new NullPointerException("Merger must not be null");
+ if(merger == null) throw new NullPointerException("Merger must not be null");
- if (!pairBound) {
+ if(!pairBound) {
/*
* If the pair isn't bound yet, bind it.
*/
@@ -220,7 +221,7 @@ public class BoundLazyPair<OldLeft, OldRight, NewLeft, NewRight> implements IPai
@Override
public String toString() {
- if (pairBound) return boundPair.toString();
+ if(pairBound) return boundPair.toString();
return "(un-materialized)";
}
diff --git a/base/src/main/java/bjc/utils/data/internals/BoundListHolder.java b/base/src/main/java/bjc/utils/data/internals/BoundListHolder.java
index 31178da..613f8e9 100644
--- a/base/src/main/java/bjc/utils/data/internals/BoundListHolder.java
+++ b/base/src/main/java/bjc/utils/data/internals/BoundListHolder.java
@@ -21,7 +21,7 @@ public class BoundListHolder<ContainedType> implements IHolder<ContainedType> {
* Create a new list of holders.
*
* @param toHold
- * The list of holders to, well, hold.
+ * The list of holders to, well, hold.
*/
public BoundListHolder(final IList<IHolder<ContainedType>> toHold) {
heldHolders = toHold;
@@ -29,7 +29,7 @@ public class BoundListHolder<ContainedType> implements IHolder<ContainedType> {
@Override
public <BoundType> IHolder<BoundType> bind(final Function<ContainedType, IHolder<BoundType>> binder) {
- if (binder == null) throw new NullPointerException("Binder must not be null");
+ if(binder == null) throw new NullPointerException("Binder must not be null");
final IList<IHolder<BoundType>> boundHolders = heldHolders.map((containedHolder) -> {
return containedHolder.bind(binder);
@@ -40,7 +40,7 @@ public class BoundListHolder<ContainedType> implements IHolder<ContainedType> {
@Override
public <NewType> Function<ContainedType, IHolder<NewType>> lift(final Function<ContainedType, NewType> func) {
- if (func == null) throw new NullPointerException("Function to lift must not be null");
+ if(func == null) throw new NullPointerException("Function to lift must not be null");
return (val) -> {
return new ListHolder<>(func.apply(val));
@@ -49,7 +49,7 @@ public class BoundListHolder<ContainedType> implements IHolder<ContainedType> {
@Override
public <MappedType> IHolder<MappedType> map(final Function<ContainedType, MappedType> mapper) {
- if (mapper == null) throw new NullPointerException("Mapper must not be null");
+ if(mapper == null) throw new NullPointerException("Mapper must not be null");
final IList<IHolder<MappedType>> mappedHolders = heldHolders.map((containedHolder) -> {
return containedHolder.map(mapper);
@@ -60,7 +60,7 @@ public class BoundListHolder<ContainedType> implements IHolder<ContainedType> {
@Override
public IHolder<ContainedType> transform(final UnaryOperator<ContainedType> transformer) {
- if (transformer == null) throw new NullPointerException("Transformer must not be null");
+ if(transformer == null) throw new NullPointerException("Transformer must not be null");
heldHolders.forEach((containedHolder) -> {
containedHolder.transform(transformer);
@@ -71,11 +71,10 @@ public class BoundListHolder<ContainedType> implements IHolder<ContainedType> {
@Override
public <UnwrappedType> UnwrappedType unwrap(final Function<ContainedType, UnwrappedType> unwrapper) {
- if (unwrapper == null) throw new NullPointerException("Unwrapper must not be null");
+ if(unwrapper == null) throw new NullPointerException("Unwrapper must not be null");
/*
- * @NOTE
- * Is there another way we could want to do this?
+ * @NOTE Is there another way we could want to do this?
*/
return heldHolders.randItem().unwrap(unwrapper);
}
diff --git a/base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java b/base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java
index 5467255..4803bc2 100644
--- a/base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java
+++ b/base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java
@@ -31,18 +31,18 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
private final Function<OldType, IPair<NewLeft, NewRight>> binder;
/* The new bound pair. */
- private IPair<NewLeft, NewRight> boundPair;
+ private IPair<NewLeft, NewRight> boundPair;
/* Has the pair been bound yet or not? */
- private boolean pairBound;
+ private boolean pairBound;
/**
* Create a new half-bound lazy pair.
*
* @param oldSupp
- * The supplier of the old value.
+ * The supplier of the old value.
*
* @param bindr
- * The function to use to create the pair from the old value.
+ * The function to use to create the pair from the old value.
*/
public HalfBoundLazyPair(final Supplier<OldType> oldSupp,
final Function<OldType, IPair<NewLeft, NewRight>> bindr) {
@@ -57,7 +57,7 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
final IHolder<Boolean> newPairMade = new Identity<>(pairBound);
final Supplier<NewLeft> leftSupp = () -> {
- if (!newPairMade.getValue()) {
+ if(!newPairMade.getValue()) {
/* Bind the pair if it hasn't been bound yet. */
newPair.replace(binder.apply(oldSupplier.get()));
newPairMade.replace(true);
@@ -67,7 +67,7 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
};
final Supplier<NewRight> rightSupp = () -> {
- if (!newPairMade.getValue()) {
+ if(!newPairMade.getValue()) {
/* Bind the pair if it hasn't been bound yet. */
newPair.replace(binder.apply(oldSupplier.get()));
newPairMade.replace(true);
@@ -85,7 +85,7 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
final Supplier<NewLeft> leftSupp = () -> {
IPair<NewLeft, NewRight> newPair = boundPair;
- if (!pairBound) {
+ if(!pairBound) {
newPair = binder.apply(oldSupplier.get());
}
@@ -101,7 +101,7 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
final Supplier<NewRight> rightSupp = () -> {
IPair<NewLeft, NewRight> newPair = boundPair;
- if (!pairBound) {
+ if(!pairBound) {
newPair = binder.apply(oldSupplier.get());
}
@@ -118,7 +118,7 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
final BiFunction<NewRight, OtherRight, CombinedRight> rightCombiner) {
return otherPair.bind((otherLeft, otherRight) -> {
return bind((leftVal, rightVal) -> {
- CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft);
+ CombinedLeft cLeft = leftCombiner.apply(leftVal, otherLeft);
CombinedRight cRight = rightCombiner.apply(rightVal, otherRight);
return new LazyPair<>(cLeft, cRight);
@@ -129,7 +129,7 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
@Override
public <NewLeftType> IPair<NewLeftType, NewRight> mapLeft(final Function<NewLeft, NewLeftType> mapper) {
final Supplier<NewLeftType> leftSupp = () -> {
- if (pairBound) return mapper.apply(boundPair.getLeft());
+ if(pairBound) return mapper.apply(boundPair.getLeft());
final NewLeft leftVal = binder.apply(oldSupplier.get()).getLeft();
@@ -137,7 +137,7 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
};
final Supplier<NewRight> rightSupp = () -> {
- if (pairBound) return boundPair.getRight();
+ if(pairBound) return boundPair.getRight();
return binder.apply(oldSupplier.get()).getRight();
};
@@ -148,13 +148,13 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
@Override
public <NewRightType> IPair<NewLeft, NewRightType> mapRight(final Function<NewRight, NewRightType> mapper) {
final Supplier<NewLeft> leftSupp = () -> {
- if (pairBound) return boundPair.getLeft();
+ if(pairBound) return boundPair.getLeft();
return binder.apply(oldSupplier.get()).getLeft();
};
final Supplier<NewRightType> rightSupp = () -> {
- if (pairBound) return mapper.apply(boundPair.getRight());
+ if(pairBound) return mapper.apply(boundPair.getRight());
final NewRight rightVal = binder.apply(oldSupplier.get()).getRight();
@@ -166,7 +166,7 @@ public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewL
@Override
public <MergedType> MergedType merge(final BiFunction<NewLeft, NewRight, MergedType> merger) {
- if (!pairBound) {
+ if(!pairBound) {
boundPair = binder.apply(oldSupplier.get());
pairBound = true;
diff --git a/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java b/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java
index a5c8130..57f9302 100644
--- a/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java
+++ b/base/src/main/java/bjc/utils/data/internals/WrappedLazy.java
@@ -19,13 +19,13 @@ public class WrappedLazy<ContainedType> implements IHolder<ContainedType> {
* Create a new wrapped lazy value.
*
* @param wrappedHolder
- * The holder to make lazy.
+ * The holder to make lazy.
*/
public WrappedLazy(final IHolder<ContainedType> wrappedHolder) {
held = new Lazy<>(wrappedHolder);
}
- /*
+ /*
* This has an extra parameter, because otherwise it erases to the same
* as the public one.
*
diff --git a/base/src/main/java/bjc/utils/data/internals/WrappedOption.java b/base/src/main/java/bjc/utils/data/internals/WrappedOption.java
index 872295f..6260ce4 100644
--- a/base/src/main/java/bjc/utils/data/internals/WrappedOption.java
+++ b/base/src/main/java/bjc/utils/data/internals/WrappedOption.java
@@ -19,7 +19,7 @@ public class WrappedOption<ContainedType> implements IHolder<ContainedType> {
* Create a new wrapped option.
*
* @param seedValue
- * The value to wrap.
+ * The value to wrap.
*/
public WrappedOption(final IHolder<ContainedType> seedValue) {
held = new Option<>(seedValue);
@@ -38,7 +38,7 @@ public class WrappedOption<ContainedType> implements IHolder<ContainedType> {
public <BoundType> IHolder<BoundType> bind(final Function<ContainedType, IHolder<BoundType>> binder) {
final IHolder<IHolder<BoundType>> newHolder = held.map((containedHolder) -> {
return containedHolder.bind((containedValue) -> {
- if (containedValue == null) return new Option<>(null);
+ if(containedValue == null) return new Option<>(null);
return binder.apply(containedValue);
});
@@ -58,7 +58,7 @@ public class WrappedOption<ContainedType> implements IHolder<ContainedType> {
public <MappedType> IHolder<MappedType> map(final Function<ContainedType, MappedType> mapper) {
final IHolder<IHolder<MappedType>> newHolder = held.map((containedHolder) -> {
return containedHolder.map((containedValue) -> {
- if (containedValue == null) return null;
+ if(containedValue == null) return null;
return mapper.apply(containedValue);
});
@@ -71,7 +71,7 @@ public class WrappedOption<ContainedType> implements IHolder<ContainedType> {
public IHolder<ContainedType> transform(final UnaryOperator<ContainedType> transformer) {
held.transform((containedHolder) -> {
return containedHolder.transform((containedValue) -> {
- if (containedValue == null) return null;
+ if(containedValue == null) return null;
return transformer.apply(containedValue);
});
@@ -84,7 +84,7 @@ public class WrappedOption<ContainedType> implements IHolder<ContainedType> {
public <UnwrappedType> UnwrappedType unwrap(final Function<ContainedType, UnwrappedType> unwrapper) {
return held.unwrap((containedHolder) -> {
return containedHolder.unwrap((containedValue) -> {
- if (containedValue == null) return null;
+ if(containedValue == null) return null;
return unwrapper.apply(containedValue);
});