From df972ae7dbdf051268c5cf7754e07c504524b197 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 28 Jul 2016 11:00:25 -0400 Subject: Note something to see if needs to be fixed later --- BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java | 7 +++---- .../src/main/java/bjc/utils/data/LazyPair.java | 24 ++++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java b/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java index fb1a517..112a503 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/Lazy.java @@ -16,13 +16,13 @@ import bjc.utils.funcdata.IList; * @param */ public class Lazy implements IHolder { - private Supplier valueSupplier; + private Supplier valueSupplier; private IList> actions = new FunctionalList<>(); - private boolean valueMaterialized; + private boolean valueMaterialized; - private ContainedType heldValue; + private ContainedType heldValue; /** * Create a new lazy value from the specified seed value @@ -137,7 +137,6 @@ public class Lazy implements IHolder { @Override public Function> lift( Function func) { - // TODO Auto-generated method stub return (val) -> { return new Lazy<>(func.apply(val)); }; diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java index d688e5b..e0b39cc 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/LazyPair.java @@ -13,6 +13,9 @@ import java.util.function.Supplier; * The type on the left side of the pair * @param * The type on the right side of the pair + * + * @TODO ensure we don't have any issues with values being materialized + * more than once */ public class LazyPair implements IPair { @@ -115,8 +118,8 @@ public class LazyPair } @Override - public MergedType - merge(BiFunction merger) { + public MergedType merge( + BiFunction merger) { if (!leftMaterialized) { leftValue = leftSupplier.get(); @@ -156,8 +159,8 @@ public class LazyPair } @Override - public IPair - mapLeft(Function mapper) { + public IPair mapLeft( + Function mapper) { Supplier leftSupp = () -> { if (leftMaterialized) { return mapper.apply(leftValue); @@ -178,8 +181,8 @@ public class LazyPair } @Override - public IPair - mapRight(Function mapper) { + public IPair mapRight( + Function mapper) { Supplier leftSupp = () -> { if (leftMaterialized) { return leftValue; @@ -200,11 +203,10 @@ public class LazyPair } @Override - public - IPair - combine(IPair otherPair, - BiFunction leftCombiner, - BiFunction rightCombiner) { + public IPair combine( + IPair otherPair, + BiFunction leftCombiner, + BiFunction rightCombiner) { return otherPair.bind((otherLeft, otherRight) -> { return bind((leftVal, rightVal) -> { return new LazyPair<>( -- cgit v1.2.3