Class Either.Left<A,​B>

  • Enclosing class:
    Either<A,​B>

    public static final class Either.Left<A,​B>
    extends Either<A,​B>
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      Either<B,​A> flip()
      Flip an Either<A,B> to a Either<B,A>.
      A getLeft()  
      B getRight()  
      int hashCode()  
      <X,​Y>
      Either<X,​Y>
      map​(java.util.function.Function<A,​X> leftFunction, java.util.function.Function<B,​Y> rightFunction)
      Map this Either<A,B> to a new Either<X,Y>.
      <T> T reduce​(java.util.function.Function<A,​T> leftFunction, java.util.function.Function<B,​T> rightFunction)
      Reduce an Either<A,B> to a single value type T.
      java.lang.String toString()  
      void use​(java.util.function.Consumer<A> leftConsumer, java.util.function.Consumer<B> rightConsumer)
      Pass the value of this either to a consumer.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getLeft

        public A getLeft()
        Specified by:
        getLeft in class Either<A,​B>
        Returns:
        the left value
      • getRight

        public B getRight()
        Specified by:
        getRight in class Either<A,​B>
        Returns:
        the right value
      • hashCode

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

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

        public void use​(java.util.function.Consumer<A> leftConsumer,
                        java.util.function.Consumer<B> rightConsumer)
        Description copied from class: Either
        Pass the value of this either to a consumer.
        Specified by:
        use in class Either<A,​B>
        Parameters:
        leftConsumer - the consumer for lefts
        rightConsumer - the consumer for rights
      • map

        public <X,​Y> Either<X,​Y> map​(java.util.function.Function<A,​X> leftFunction,
                                                 java.util.function.Function<B,​Y> rightFunction)
        Description copied from class: Either
        Map this Either<A,B> to a new Either<X,Y>.
        Specified by:
        map in class Either<A,​B>
        Type Parameters:
        X - the new left type
        Y - the new right type
        Parameters:
        leftFunction - function to convert A to X
        rightFunction - function to convert B to Y
        Returns:
        a new Either<X,Y>
      • reduce

        public <T> T reduce​(java.util.function.Function<A,​T> leftFunction,
                            java.util.function.Function<B,​T> rightFunction)
        Description copied from class: Either
        Reduce an Either<A,B> to a single value type T.
        Specified by:
        reduce in class Either<A,​B>
        Type Parameters:
        T - the result type
        Parameters:
        leftFunction - function to convert A to T
        rightFunction - function to convert B to T
        Returns:
        a value typed T
      • flip

        public Either<B,​A> flip()
        Description copied from class: Either
        Flip an Either<A,B> to a Either<B,A>.
        Specified by:
        flip in class Either<A,​B>
        Returns:
        a new either with types flipped