Class Either<L,​R>

  • Type Parameters:
    L - The left object type
    R - The right object type

    public final class Either<L,​R>
    extends Object
    A functional programming concept that will contain either the left object or the right object, but never both.

    This can be used in a variety of functional data flows.

    • Constructor Detail

      • Either

        protected Either​(L inputLeft,
                         R inputRight)
    • Method Detail

      • left

        public static <A> Either<A,​?> left​(A l)
        Creates an Either object containing the given object on the left.

        The type of the right object is undefined.

        Type Parameters:
        A - The left object type
        Parameters:
        l - The non-null left object
        Returns:
        The Either object
      • right

        public static <B> Either<?,​B> right​(B r)
        Creates an Either object containing the given object on the right.

        The type of the left object is undefined.

        Type Parameters:
        B - The right object type
        Parameters:
        r - The non-null right object
        Returns:
        The Either object
      • hasLeft

        public boolean hasLeft()
        Returns:
        True if this Either has a left object
      • hasRight

        public boolean hasRight()
        Returns:
        True if this Either has a right object