From 889fac2bdf993dc86f64a8893c0260fdcf848acb Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 10 Apr 2017 16:40:33 -0400 Subject: Cleanup --- .../src/main/java/bjc/utils/data/ListHolder.java | 47 ++++++++++------------ 1 file changed, 21 insertions(+), 26 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/ListHolder.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/ListHolder.java b/BJC-Utils2/src/main/java/bjc/utils/data/ListHolder.java index 8807312..142057c 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/data/ListHolder.java +++ b/BJC-Utils2/src/main/java/bjc/utils/data/ListHolder.java @@ -1,12 +1,12 @@ package bjc.utils.data; +import java.util.function.Function; +import java.util.function.UnaryOperator; + import bjc.utils.data.internals.BoundListHolder; import bjc.utils.funcdata.FunctionalList; import bjc.utils.funcdata.IList; -import java.util.function.Function; -import java.util.function.UnaryOperator; - /** * A holder that represents a set of non-deterministic computations * @@ -25,50 +25,50 @@ public class ListHolder implements IHolder { * The possible values for the computation */ @SafeVarargs - public ListHolder(ContainedType... values) { + public ListHolder(final ContainedType... values) { heldValues = new FunctionalList<>(); if (values != null) { - for (ContainedType containedValue : values) { + for (final ContainedType containedValue : values) { heldValues.add(containedValue); } } } - private ListHolder(IList toHold) { + private ListHolder(final IList toHold) { heldValues = toHold; } @Override - public IHolder bind(Function> binder) { - IList> boundValues = heldValues.map(binder); + public IHolder bind(final Function> binder) { + final IList> boundValues = heldValues.map(binder); return new BoundListHolder<>(boundValues); } @Override - public Function> lift(Function func) { + public Function> lift(final Function func) { return val -> { return new ListHolder<>(new FunctionalList<>(func.apply(val))); }; } @Override - public IHolder map(Function mapper) { - IList mappedValues = heldValues.map(mapper); + public IHolder map(final Function mapper) { + final IList mappedValues = heldValues.map(mapper); return new ListHolder<>(mappedValues); } @Override - public IHolder transform(UnaryOperator transformer) { + public IHolder transform(final UnaryOperator transformer) { heldValues = heldValues.map(transformer); return this; } @Override - public UnwrappedType unwrap(Function unwrapper) { + public UnwrappedType unwrap(final Function unwrapper) { return unwrapper.apply(heldValues.randItem()); } @@ -82,27 +82,22 @@ public class ListHolder implements IHolder { final int prime = 31; int result = 1; - result = prime * result + ((heldValues == null) ? 0 : heldValues.hashCode()); + result = prime * result + (heldValues == null ? 0 : heldValues.hashCode()); return result; } @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (!(obj instanceof ListHolder)) - return false; + public boolean equals(final Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (!(obj instanceof ListHolder)) return false; - ListHolder other = (ListHolder) obj; + final ListHolder other = (ListHolder) obj; if (heldValues == null) { - if (other.heldValues != null) - return false; - } else if (!heldValues.equals(other.heldValues)) - return false; + if (other.heldValues != null) return false; + } else if (!heldValues.equals(other.heldValues)) return false; return true; } -- cgit v1.2.3