From 44be6e6cd7671dd243056107ffa6201504f7fbce Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Sun, 25 Jun 2023 15:50:38 -0400 Subject: Update a number of things --- src/main/java/bjc/data/Either.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/main/java/bjc/data/Either.java') diff --git a/src/main/java/bjc/data/Either.java b/src/main/java/bjc/data/Either.java index 42d2e99..07845f6 100644 --- a/src/main/java/bjc/data/Either.java +++ b/src/main/java/bjc/data/Either.java @@ -185,6 +185,14 @@ public class Either { return rightVal; } + /** + * Change the type of the right-side of this either. + * + * Works only for left Eithers. + * + * @param The new type for the right side + * @return The either with the new type. + */ @SuppressWarnings("unchecked") public Either newRight() { if (isLeft) return (Either) this; @@ -192,6 +200,14 @@ public class Either { throw new NoSuchElementException("Can't replace right type on right Either"); } + /** + * Change the type of the left-side of this either. + * + * Works only for right Eithers. + * + * @param The new type for the left side + * @return The either with the new type. + */ @SuppressWarnings("unchecked") public Either newLeft() { if (isLeft) @@ -199,6 +215,14 @@ public class Either { return (Either) this; } + /** + * Collapse an Either with the same type on both sides. + * + * @param The type of the either + * @param eth The either to collapse + * + * @return The collapsed either + */ public static T collapse(Either eth) { return eth.extract(ID.id(), ID.id()); } -- cgit v1.2.3