summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/experimental/IPair.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2016-04-17 15:01:44 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2016-04-17 15:01:44 -0400
commit77fcc58d1facffbc3af50be8c05985350e9f1355 (patch)
treeb7b81d24c107e644924dc526f8bb034efc62d2dc /BJC-Utils2/src/main/java/bjc/utils/data/experimental/IPair.java
parenta5850915df72f5968fd1b281eb9e455d50c580ee (diff)
Code maintenace and changes
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/experimental/IPair.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/data/experimental/IPair.java97
1 files changed, 0 insertions, 97 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/experimental/IPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/experimental/IPair.java
deleted file mode 100644
index f5ca240..0000000
--- a/BJC-Utils2/src/main/java/bjc/utils/data/experimental/IPair.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package bjc.utils.data.experimental;
-
-import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-
-/**
- * Represents a pair of values
- *
- * @author ben
- * @param <LeftType>
- * The type of the left side of the pair
- * @param <RightType>
- * The type of the right side of the pair
- *
- */
-public interface IPair<LeftType, RightType> {
- /**
- * Bind a function to the left value in this pair
- *
- * @param <BoundLeft>
- * The type of the bound value
- * @param leftBinder
- * The function to use to bind
- * @return A pair with the left type bound
- */
- public <BoundLeft> IPair<BoundLeft, RightType> bindLeft(
- Function<LeftType, IPair<BoundLeft, RightType>> leftBinder);
-
- /**
- * Bind a function to the right value in this pair
- *
- * @param <BoundRight>
- * The type of the bound value
- * @param rightBinder
- * The function to use to bind
- * @return A pair with the right type bound
- */
- public <BoundRight> IPair<LeftType, BoundRight> bindRight(
- Function<RightType, IPair<LeftType, BoundRight>> rightBinder);
-
- /**
- * Bind a function across the values in this pair
- *
- * @param <BoundLeft>
- * The type of the bound left
- * @param <BoundRight>
- * The type of the bound right
- * @param binder
- * The function to bind with
- * @return The bound pair
- */
- public <BoundLeft, BoundRight> IPair<BoundLeft, BoundRight> bind(
- BiFunction<LeftType, RightType, IPair<BoundLeft, BoundRight>> binder);
-
- /**
- * Merge the two values in this pair into a single value
- *
- * @param <MergedType>
- * The type of the single value
- * @param merger
- * The function to use for merging
- * @return The pair, merged into a single value
- */
- public <MergedType> MergedType merge(
- BiFunction<LeftType, RightType, MergedType> merger);
-
- /**
- * Get the value on the left side of the pair
- *
- * @return The value on the left side of the pair
- */
- public default LeftType getLeft() {
- return merge((leftValue, rightValue) -> leftValue);
- }
-
- /**
- * Get the value on the right side of the pair
- *
- * @return The value on the right side of the pair
- */
- public default RightType getRight() {
- return merge((leftValue, rightValue) -> rightValue);
- }
-
- /**
- * Immediately perfom the specified action with the contents of this pair
- * @param consumer The action to perform on the pair
- */
- public default void doWith(BiConsumer<LeftType, RightType> consumer) {
- merge((leftValue, rightValue) -> {
- consumer.accept(leftValue, rightValue);
-
- return null;
- });
- }
-}