/** * Constructs a right side of the disjoint union, as opposed to the Left side. * * @param value The value of the right side * @param <L> the left type * @param <R> the right type * @return A right sided disjoint union */ public static <L, R> Either<L, R> Right(R value) { return new Either<L, R>(Optional.<L>empty(), Optional.of(value)); }
/** * Constructs a left side of the disjoint union, as opposed to the Right side. * * @param value The value of the left side * @param <L> the left type * @param <R> the right type * @return A left sided disjoint union */ public static <L, R> Either<L, R> Left(L value) { return new Either<L, R>(Optional.of(value), Optional.<R>empty()); }
/** * Constructs a left side of the disjoint union, as opposed to the Right side. * * @param value The value of the left side * @param <L> the left type * @param <R> the right type * @return A left sided disjoint union */ public static <L, R> Either<L, R> Left(L value) { return new Either<L, R>(Optional.of(value), Optional.<R>empty()); }
public static <A, B> Either<A, B> _1(A value) { return new Either(Some(value), None); }
/** * Constructs a right side of the disjoint union, as opposed to the Left side. * * @param value The value of the right side * @return A right sided disjoint union */ public static <L, R> Either<L, R> Right(R value) { return new Either<L, R>(Optional.<L>empty(), Optional.of(value)); }
/** * Constructs a left side of the disjoint union, as opposed to the Right side. * * @param value The value of the left side * @return A left sided disjoint union */ public static <L, R> Either<L, R> Left(L value) { return new Either<L, R>(Optional.of(value), Optional.<R>empty()); }
public static <A, B> Either<A, B> _2(B value) { return new Either(None, Some(value)); }
/** * Constructs a right side of the disjoint union, as opposed to the Left side. * * @param value The value of the right side * @param <L> the left type * @param <R> the right type * @return A right sided disjoint union */ public static <L, R> Either<L, R> Right(R value) { return new Either<L, R>(Optional.<L>empty(), Optional.of(value)); }
/** * Constructs a right side of the disjoint union, as opposed to the Left side. * * @param value The value of the right side * @param <L> the left type * @param <R> the right type * @return A right sided disjoint union */ public static <L, R> Either<L, R> Right(R value) { return new Either<L, R>(Optional.<L>empty(), Optional.of(value)); }
/** * Constructs a left side of the disjoint union, as opposed to the Right side. * * @param value The value of the left side * @param <L> the left type * @param <R> the right type * @return A left sided disjoint union */ public static <L, R> Either<L, R> Left(L value) { return new Either<L, R>(Optional.of(value), Optional.<R>empty()); }
/** * Constructs a left side of the disjoint union, as opposed to the Right side. * * @param value The value of the left side * @return A left sided disjoint union */ public static <A, B> Either<A, B> Left(A value) { return new Either<A, B>(Some(value), None()); }
/** * Constructs a right side of the disjoint union, as opposed to the Left side. * * @param value The value of the right side * @return A right sided disjoint union */ public static <A, B> Either<A, B> Right(B value) { return new Either<A, B>(None(), Some(value)); }