Class Left<L,​R>

  • Type Parameters:
    L - The type for the Left side
    R - The type for the Right side (not used for this class)
    All Implemented Interfaces:
    java.io.Serializable, Either<L,​R>

    public final class Left<L,​R>
    extends java.lang.Object
    implements Either<L,​R>, java.io.Serializable
    Represents the Left side of an Either.
    Since:
    1.1
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Left​(L value)
      Creates an instance wrapping the provide value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T fold​(java.util.function.Function<L,​T> func_left, java.util.function.Function<R,​T> func_right)
      Applies the provided func_left to the wrapped value and returns the result.
      boolean isRight()
      Always returns false.
      Either<R,​L> swap()
      Returns a Right containing the value for this instance.
      java.lang.String toString()
      Returns a String representation of the instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Left

        public Left​(L value)
        Creates an instance wrapping the provide value.
        Parameters:
        value - The value wrapped by this instance
        Since:
        1.1
    • Method Detail

      • fold

        public <T> T fold​(java.util.function.Function<L,​T> func_left,
                          java.util.function.Function<R,​T> func_right)
        Applies the provided func_left to the wrapped value and returns the result.
        Specified by:
        fold in interface Either<L,​R>
        Type Parameters:
        T - The type to return from func_left/func_right
        Parameters:
        func_left - The function to apply in case this is a Left
        func_right - The function to apply in case this is a Right
        Returns:
        The result from applying either func_left or func_right
        Since:
        1.1
      • isRight

        public boolean isRight()
        Always returns false.
        Specified by:
        isRight in interface Either<L,​R>
        Returns:
        true if this instance is Right.
        Since:
        1.1
      • swap

        public Either<R,​L> swap()
        Returns a Right containing the value for this instance.
        Specified by:
        swap in interface Either<L,​R>
        Returns:
        The swapped version of this instance
        Since:
        1.1
      • toString

        public java.lang.String toString()
        Returns a String representation of the instance.
        Overrides:
        toString in class java.lang.Object
        Since:
        1.1