summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2016-07-28 16:44:36 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2016-07-28 16:44:36 -0400
commitdca8e9f586fd595a7995f07788318fb92b8cce79 (patch)
tree4fdf216d4a30c2c663d4a429f79cfa471c8579c4 /BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java
parentb1317e5e62bb044cd8a676cb3fc2da86e9922caf (diff)
Format/Cleanup pass
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java49
1 files changed, 23 insertions, 26 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java
index 1256e31..b6cd715 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/BoundLazy.java
@@ -15,28 +15,27 @@ class BoundLazy<OldType, BoundContainedType>
/*
* The old value
*/
- private Supplier<IHolder<OldType>> oldSupplier;
+ private Supplier<IHolder<OldType>> oldSupplier;
/*
* The function to use to transform the old value into a new value
*/
- private Function<OldType, IHolder<BoundContainedType>> binder;
+ private Function<OldType, IHolder<BoundContainedType>> binder;
/*
* The bound value being held
*/
- private IHolder<BoundContainedType> boundHolder;
+ private IHolder<BoundContainedType> boundHolder;
/*
* Whether the bound value has been actualized or not
*/
- private boolean holderBound;
+ private boolean holderBound;
/*
* Transformations currently pending on the bound value
*/
- private IList<UnaryOperator<BoundContainedType>> actions =
- new FunctionalList<>();
+ private IList<UnaryOperator<BoundContainedType>> actions = new FunctionalList<>();
/*
* Create a new bound lazy value
@@ -48,13 +47,12 @@ class BoundLazy<OldType, BoundContainedType>
}
@Override
- public <BoundType> IHolder<BoundType>
- bind(Function<BoundContainedType, IHolder<BoundType>> bindr) {
+ public <BoundType> IHolder<BoundType> bind(
+ Function<BoundContainedType, IHolder<BoundType>> bindr) {
/*
* Prepare a list of pending actions
*/
- IList<UnaryOperator<BoundContainedType>> pendingActions =
- new FunctionalList<>();
+ IList<UnaryOperator<BoundContainedType>> pendingActions = new FunctionalList<>();
actions.forEach(pendingActions::add);
/*
@@ -82,11 +80,18 @@ class BoundLazy<OldType, BoundContainedType>
}
@Override
- public <MappedType> IHolder<MappedType>
- map(Function<BoundContainedType, MappedType> mapper) {
+ public <NewType> Function<BoundContainedType, IHolder<NewType>> lift(
+ Function<BoundContainedType, NewType> func) {
+ return (val) -> {
+ return new Lazy<>(func.apply(val));
+ };
+ }
+
+ @Override
+ public <MappedType> IHolder<MappedType> map(
+ Function<BoundContainedType, MappedType> mapper) {
// Prepare a list of pending actions
- IList<UnaryOperator<BoundContainedType>> pendingActions =
- new FunctionalList<>();
+ IList<UnaryOperator<BoundContainedType>> pendingActions = new FunctionalList<>();
actions.forEach(pendingActions::add);
// Prepare the new supplier
@@ -117,28 +122,20 @@ class BoundLazy<OldType, BoundContainedType>
}
@Override
- public IHolder<BoundContainedType>
- transform(UnaryOperator<BoundContainedType> transformer) {
+ public IHolder<BoundContainedType> transform(
+ UnaryOperator<BoundContainedType> transformer) {
actions.add(transformer);
return this;
}
@Override
- public <UnwrappedType> UnwrappedType
- unwrap(Function<BoundContainedType, UnwrappedType> unwrapper) {
+ public <UnwrappedType> UnwrappedType unwrap(
+ Function<BoundContainedType, UnwrappedType> unwrapper) {
if (!holderBound) {
boundHolder = oldSupplier.get().unwrap(binder::apply);
}
return boundHolder.unwrap(unwrapper);
}
-
- @Override
- public <NewType> Function<BoundContainedType, IHolder<NewType>>
- lift(Function<BoundContainedType, NewType> func) {
- return (val) -> {
- return new Lazy<>(func.apply(val));
- };
- }
} \ No newline at end of file