Class EitherLens


  • public final class EitherLens
    extends java.lang.Object
    Lenses for Either.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private EitherLens()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <L,​R>
      Lens.Simple<Either<L,​R>,​Maybe<L>>
      _left()
      Convenience static factory method for creating a lens over left values, wrapping them in a Maybe.
      static <L,​R>
      Lens.Simple<Either<L,​R>,​Maybe<R>>
      _right()
      Convenience static factory method for creating a lens over right values, wrapping them in a Maybe.
      • Methods inherited from class java.lang.Object

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

      • EitherLens

        private EitherLens()
    • Method Detail

      • _right

        public static <L,​R> Lens.Simple<Either<L,​R>,​Maybe<R>> _right()
        Convenience static factory method for creating a lens over right values, wrapping them in a Maybe. When setting, a Maybe.nothing() value means to leave the Either unaltered, where as a Maybe.just(A) value replaces the either with a right over the Maybe.

        Note that this lens is NOT lawful, since "you get back what you put in" fails for Maybe.nothing().

        Type Parameters:
        L - the left parameter type
        R - the right parameter type
        Returns:
        a lens that focuses on right values
      • _left

        public static <L,​R> Lens.Simple<Either<L,​R>,​Maybe<L>> _left()
        Convenience static factory method for creating a lens over left values, wrapping them in a Maybe. When setting, a Maybe.nothing() value means to leave the Either unaltered, where as a Maybe.just(A) value replaces the either with a left over the Maybe.

        Note that this lens is NOT lawful, since "you get back what you put in" fails for Maybe.nothing().

        Type Parameters:
        L - the left parameter type
        R - the right parameter type
        Returns:
        a lens that focuses on left values