Class Either<A,B>

java.lang.Object
org.opencastproject.util.data.Either<A,B>

public abstract class Either<A,B> extends Object
An algebraic data type representing a disjoint union. By convention left is considered to represent an error while right represents a value. This implementation of Either is much simpler than implementations you may know from other languages or libraries.
  • Method Details

    • left

      public abstract Either<A,B>.LeftProjection<A,B> left()
    • right

      public abstract Either<A,B>.RightProjection<A,B> right()
    • fold

      public abstract <X> X fold(Either.Match<A,B,X> visitor)
    • fold

      public abstract <X> X fold(Function<? super A,? extends X> left, Function<? super B,? extends X> right)
    • isLeft

      public abstract boolean isLeft()
    • isRight

      public abstract boolean isRight()
    • left

      public static <A, B> Either<A,B> left(A left)
      Create a left.
    • right

      public static <A, B> Either<A,B> right(B right)
      Create a right.