From fff6dc5d43539af05ae2679640240b8545b36947 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Tue, 10 May 2016 21:58:08 -0400 Subject: Added interface to JDK collector API --- .../java/bjc/utils/funcutils/CollectorUtils.java | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 BJC-Utils2/src/main/java/bjc/utils/funcutils/CollectorUtils.java (limited to 'BJC-Utils2/src/main/java/bjc/utils/funcutils/CollectorUtils.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/funcutils/CollectorUtils.java b/BJC-Utils2/src/main/java/bjc/utils/funcutils/CollectorUtils.java new file mode 100644 index 0000000..a44059b --- /dev/null +++ b/BJC-Utils2/src/main/java/bjc/utils/funcutils/CollectorUtils.java @@ -0,0 +1,41 @@ +package bjc.utils.funcutils; + +import java.util.stream.Collector; + +import bjc.utils.data.IHolder; +import bjc.utils.data.IPair; + +/** + * Utilities for producing implementations of {@link Collector} + * + * @author ben + * + */ +public class CollectorUtils { + /** + * Create a collector that applies two collectors at once + * + * @param + * The type of the collection to collect from + * @param + * The intermediate type of the first collector + * @param + * The intermediate type of the second collector + * @param + * The final type of the first collector + * @param + * The final type of the second collector + * @param firstCollector + * The first collector to use + * @param secondCollector + * The second collector to use + * @return A collector that functions as mentioned above + */ + public static + Collector>, IPair> + compoundCollect( + Collector firstCollector, + Collector secondCollector) { + return new CompoundCollector<>(firstCollector, secondCollector); + } +} -- cgit v1.2.3