summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java
diff options
context:
space:
mode:
authorEVE <EVE@EVE-PC>2017-03-14 12:07:14 -0400
committerEVE <EVE@EVE-PC>2017-03-14 12:07:14 -0400
commit504ca816530efdff06bc202e0432ebd354aec304 (patch)
tree4836932fb81d1d625470502c78c94d202c9a7420 /BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java
parent5c1163df17c46f7d3e15b6c7949c38843ec56146 (diff)
Cleanup
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java38
1 files changed, 13 insertions, 25 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java
index 57bf006..0ec69f0 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/internals/BoundLazy.java
@@ -1,14 +1,14 @@
package bjc.utils.data.internals;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import java.util.function.UnaryOperator;
-
import bjc.utils.data.IHolder;
import bjc.utils.data.Lazy;
import bjc.utils.funcdata.FunctionalList;
import bjc.utils.funcdata.IList;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.function.UnaryOperator;
+
/**
* Implements a lazy holder that has been bound
*/
@@ -48,9 +48,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
@Override
public <BoundType> IHolder<BoundType> bind(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
@@ -67,7 +65,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
/*
* Bind the value if it hasn't been bound before
*/
- if (!holderBound) {
+ if(!holderBound) {
oldHolder = oldSupplier.get().unwrap(binder);
}
@@ -85,9 +83,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
@Override
public <NewType> Function<BoundContainedType, IHolder<NewType>> lift(
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));
@@ -96,9 +92,7 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
@Override
public <MappedType> IHolder<MappedType> map(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
IList<UnaryOperator<BoundContainedType>> pendingActions = new FunctionalList<>();
@@ -109,7 +103,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);
}
@@ -123,18 +117,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(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);
@@ -143,11 +133,9 @@ public class BoundLazy<OldType, BoundContainedType> implements IHolder<BoundCont
@Override
public <UnwrappedType> UnwrappedType unwrap(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);
}