summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2016-05-10 21:58:08 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2016-05-10 21:58:08 -0400
commitfff6dc5d43539af05ae2679640240b8545b36947 (patch)
tree89dc91bdc013415b76351a22126bffe86a750d7d /BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
parent507f506093c84ae764d0c26b24d9d055e8613aae (diff)
Added interface to JDK collector API
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.java12
1 files changed, 12 insertions, 0 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 eb421bc..1fc0d19 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/data/Pair.java
@@ -104,4 +104,16 @@ public class Pair<LeftType, RightType>
return new Pair<>(leftValue, mapper.apply(rightValue));
}
+
+ @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));
+ });
+ }
} \ No newline at end of file