Class EitherLens
- java.lang.Object
-
- com.jnape.palatable.lambda.optics.lenses.EitherLens
-
public final class EitherLens extends java.lang.ObjectLenses forEither.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateEitherLens()
-
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 aMaybe.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 aMaybe.
-
-
-
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 aMaybe. When setting, aMaybe.nothing()value means to leave theEitherunaltered, where as aMaybe.just(A)value replaces the either with a right over theMaybe.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 typeR- 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 aMaybe. When setting, aMaybe.nothing()value means to leave theEitherunaltered, where as aMaybe.just(A)value replaces the either with a left over theMaybe.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 typeR- the right parameter type- Returns:
- a lens that focuses on left values
-
-