summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/Pair.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/Pair.java
parentb1317e5e62bb044cd8a676cb3fc2da86e9922caf (diff)
Format/Cleanup pass
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/Pair.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/Pair.java51
1 files changed, 25 insertions, 26 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java b/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
index 1fc0d19..1000fc0 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
@@ -70,24 +70,19 @@ public class Pair<LeftType, RightType>
}
@Override
- public <MergedType> MergedType
- merge(BiFunction<LeftType, RightType, MergedType> merger) {
- if (merger == null) {
- throw new NullPointerException("Merger must not be null");
- }
-
- return merger.apply(leftValue, rightValue);
- }
-
- @Override
- public String toString() {
- return "pair[l=" + leftValue.toString() + ", r="
- + rightValue.toString() + "]";
+ public <OtherLeft, OtherRight, CombinedLeft, CombinedRight> IPair<CombinedLeft, CombinedRight> combine(
+ IPair<OtherLeft, OtherRight> otherPair,
+ BiFunction<LeftType, OtherLeft, CombinedLeft> leftCombiner,
+ BiFunction<RightType, OtherRight, CombinedRight> rightCombiner) {
+ return otherPair.bind((otherLeft, otherRight) -> {
+ return new Pair<>(leftCombiner.apply(leftValue, otherLeft),
+ rightCombiner.apply(rightValue, otherRight));
+ });
}
@Override
- public <NewLeft> IPair<NewLeft, RightType>
- mapLeft(Function<LeftType, NewLeft> mapper) {
+ public <NewLeft> IPair<NewLeft, RightType> mapLeft(
+ Function<LeftType, NewLeft> mapper) {
if (mapper == null) {
throw new NullPointerException("Mapper must not be null");
}
@@ -96,8 +91,8 @@ public class Pair<LeftType, RightType>
}
@Override
- public <NewRight> IPair<LeftType, NewRight>
- mapRight(Function<RightType, NewRight> mapper) {
+ public <NewRight> IPair<LeftType, NewRight> mapRight(
+ Function<RightType, NewRight> mapper) {
if (mapper == null) {
throw new NullPointerException("Mapper must not be null");
}
@@ -106,14 +101,18 @@ public class Pair<LeftType, RightType>
}
@Override
- public <OtherLeft, OtherRight, CombinedLeft, CombinedRight>
- IPair<CombinedLeft, CombinedRight>
- combine(IPair<OtherLeft, OtherRight> otherPair,
- BiFunction<LeftType, OtherLeft, CombinedLeft> leftCombiner,
- BiFunction<RightType, OtherRight, CombinedRight> rightCombiner) {
- return otherPair.bind((otherLeft, otherRight) -> {
- return new Pair<>(leftCombiner.apply(leftValue, otherLeft),
- rightCombiner.apply(rightValue, otherRight));
- });
+ public <MergedType> MergedType merge(
+ BiFunction<LeftType, RightType, MergedType> merger) {
+ if (merger == null) {
+ throw new NullPointerException("Merger must not be null");
+ }
+
+ return merger.apply(leftValue, rightValue);
+ }
+
+ @Override
+ public String toString() {
+ return "pair[l=" + leftValue.toString() + ", r="
+ + rightValue.toString() + "]";
}
} \ No newline at end of file