From b3eb57f0796ef79f58ed76a1baf1cdb315772b6a Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 29 Feb 2016 09:27:10 -0500 Subject: Factored interface out of Pair --- BJC-Utils2/src/main/java/bjc/utils/data/IPair.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 BJC-Utils2/src/main/java/bjc/utils/data/IPair.java (limited to 'BJC-Utils2/src/main/java/bjc/utils/data/IPair.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/data/IPair.java b/BJC-Utils2/src/main/java/bjc/utils/data/IPair.java new file mode 100644 index 0000000..9da7d22 --- /dev/null +++ b/BJC-Utils2/src/main/java/bjc/utils/data/IPair.java @@ -0,0 +1,33 @@ +package bjc.utils.data; + +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; + +public interface IPair { + + /** + * Create a new pair by applying the given functions to the left/right. + * Does not change the internal contents of this pair. + * + * @param lf + * The function to apply to the left value. + * @param rf + * The function to apply to the right value. + * @return A new pair containing the two modified values. + */ + IPair apply(Function lf, Function rf); + + /** + * Collapse this pair to a single value. Does not change the internal + * contents of this pair. + * + * @param bf + * The function to use to collapse the pair. + * @return The collapsed value. + */ + E merge(BiFunction bf); + + void doWith(BiConsumer bc); + +} \ No newline at end of file -- cgit v1.2.3