diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2018-02-12 22:44:26 -0500 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2018-02-12 22:44:26 -0500 |
| commit | ae51c587c53f7ca311e556e3cbd0c5566d6c2843 (patch) | |
| tree | a6bbb0baaa20300ad9949425455ea890c021d046 /base/src/main/java/bjc/utils/data | |
| parent | 32f5da54c628408c96db09d279f3a7ef44b3bd19 (diff) | |
Update
Diffstat (limited to 'base/src/main/java/bjc/utils/data')
| -rw-r--r-- | base/src/main/java/bjc/utils/data/Lazy.java | 57 | ||||
| -rw-r--r-- | base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java | 1 |
2 files changed, 30 insertions, 28 deletions
diff --git a/base/src/main/java/bjc/utils/data/Lazy.java b/base/src/main/java/bjc/utils/data/Lazy.java index fcebb70..4ffcead 100644 --- a/base/src/main/java/bjc/utils/data/Lazy.java +++ b/base/src/main/java/bjc/utils/data/Lazy.java @@ -15,7 +15,7 @@ import bjc.utils.funcdata.IList; * @author ben * * @param <ContainedType> - * The type of the value being held. + * The type of the value being held. */ public class Lazy<ContainedType> implements IHolder<ContainedType> { /* The supplier of the type. */ @@ -32,7 +32,7 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> { * Create a new lazy value from the specified seed value. * * @param value - * The seed value to use. + * The seed value to use. */ public Lazy(final ContainedType value) { heldValue = value; @@ -44,7 +44,7 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> { * Create a new lazy value from the specified value source. * * @param supp - * The source of a value to use. + * The source of a value to use. */ public Lazy(final Supplier<ContainedType> supp) { valueSupplier = new SingleSupplier<>(supp); @@ -66,7 +66,7 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> { actions.forEach(pendingActions::add); final Supplier<ContainedType> supplier = () -> { - if (valueMaterialized) return heldValue; + if(valueMaterialized) return heldValue; return valueSupplier.get(); }; @@ -92,7 +92,7 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> { return new Lazy<>(() -> { ContainedType currVal = heldValue; - if (!valueMaterialized) { + if(!valueMaterialized) { currVal = valueSupplier.get(); } @@ -103,10 +103,12 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> { @Override public String toString() { - if (valueMaterialized) { - if (actions.isEmpty()) + if(valueMaterialized) { + if(actions.isEmpty()) { return String.format("value[v='%s']", heldValue); - else return String.format("value[v='%s'] (has pending transforms)", heldValue); + } + + return String.format("value[v='%s'] (has pending transforms)", heldValue); } return "(unmaterialized)"; @@ -121,7 +123,7 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> { @Override public <UnwrappedType> UnwrappedType unwrap(final Function<ContainedType, UnwrappedType> unwrapper) { - if (!valueMaterialized) { + if(!valueMaterialized) { heldValue = valueSupplier.get(); valueMaterialized = true; @@ -150,23 +152,24 @@ 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; - if (valueMaterialized != other.valueMaterialized) return false; + if(valueMaterialized != other.valueMaterialized) return false; - if (valueMaterialized) { - if (heldValue == null) { - if (other.heldValue != null) return false; - } else if (!heldValue.equals(other.heldValue)) return false; - } else return false; + if(valueMaterialized) { + if(heldValue == null) { + if(other.heldValue != null) return false; + } else if(!heldValue.equals(other.heldValue)) return false; + } else + return false; - if (actions == null) { - if (other.actions != null) return false; - } else if (actions.getSize() > 0 || other.actions.getSize() > 0) return false; + if(actions == null) { + if(other.actions != null) return false; + } else if(actions.getSize() > 0 || other.actions.getSize() > 0) return false; return true; } @@ -175,10 +178,9 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> { * Create a new lazy container with an already present value. * * @param val - * The value for the lazy container. + * The value for the lazy container. * - * @return - * A new lazy container holding that value. + * @return A new lazy container holding that value. */ public static <ContainedType> Lazy<ContainedType> lazy(final ContainedType val) { return new Lazy<>(val); @@ -188,11 +190,10 @@ public class Lazy<ContainedType> implements IHolder<ContainedType> { * Create a new lazy container with a suspended value. * * @param supp - * The suspended value for the lazy container. + * The suspended value for the lazy container. * - * @return - * A new lazy container that will un-suspend the value when - * necessary. + * @return A new lazy container that will un-suspend the value when + * necessary. */ public static <ContainedType> Lazy<ContainedType> lazy(final Supplier<ContainedType> supp) { return new Lazy<>(supp); 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 c3606ef..5467255 100644 --- a/base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java +++ b/base/src/main/java/bjc/utils/data/internals/HalfBoundLazyPair.java @@ -22,6 +22,7 @@ import bjc.utils.data.LazyPair; * * @author Ben Culkin */ +@SuppressWarnings("javadoc") public class HalfBoundLazyPair<OldType, NewLeft, NewRight> implements IPair<NewLeft, NewRight> { /* The supplier of the old value. */ private final Supplier<OldType> oldSupplier; |
