Class Either.Left<L,​R>

  • All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    Either<L,​R>

    static final class Either.Left<L,​R>
    extends Either<L,​R>
    • Field Detail

      • value

        private final L value
    • Constructor Detail

      • Left

        public Left​(L value)
    • Method Detail

      • isLeft

        public boolean isLeft()
        Description copied from class: Either
        Returns true if this either is a left, false otherwise.
        Specified by:
        isLeft in class Either<L,​R>
        Returns:
        true if this either is a left, false otherwise.
      • isRight

        public boolean isRight()
        Description copied from class: Either
        Returns true if this either is a right, false otherwise.
        Specified by:
        isRight in class Either<L,​R>
        Returns:
        true if this either is a right, false otherwise.
      • swap

        public Either<R,​L> swap()
        Description copied from class: Either
        If this is a left, then return the left value in right, or vice versa.
        Specified by:
        swap in class Either<L,​R>
        Returns:
        an Either that is a Left if this is a Right or a Right if this is a Left. The value remains the same.
      • fold

        public <V> V fold​(java.util.function.Function<? super L,​V> ifLeft,
                          java.util.function.Function<? super R,​V> ifRight)
        Description copied from class: Either
        Applies the function to the wrapped value, applying ifLeft if this is a Left and ifRight if this is a Right.
        Specified by:
        fold in class Either<L,​R>
        Type Parameters:
        V - the destination type
        Parameters:
        ifLeft - the function to apply if this is a Left
        ifRight - the function to apply if this is a Right
        Returns:
        the result of the applies function
      • bimap

        public <LL,​RR> Either<LL,​RR> bimap​(java.util.function.Function<? super L,​? extends LL> ifLeft,
                                                       java.util.function.Function<? super R,​? extends RR> ifRight)
        Description copied from class: Either
        Map the given functions across the appropriate side.
        Specified by:
        bimap in class Either<L,​R>
        Type Parameters:
        LL - the LHS type
        RR - the RHS type
        Parameters:
        ifLeft - The function to map if this Either is a left.
        ifRight - The function to map if this Either is a right.
        Returns:
        A new either value after mapping with the appropriate function applied.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object