Beispiel #1
0
 /**
  * Takes an <code>Either</code> to its contained value within left or right.
  *
  * @param e The either to reduce.
  * @return An <code>Either</code> to its contained value within left or right.
  */
 public static <A> A reduce(final Either<A, A> e) {
   return e.isLeft() ? e.left().value() : e.right().value();
 }
Beispiel #2
0
 /**
  * Returns the value of this projection or fails with the given error message.
  *
  * @param err The error message to fail with.
  * @return The value of this projection
  */
 public A valueE(final P1<String> err) {
   if (e.isLeft())
     //noinspection CastToConcreteClass
     return ((Left<A, B>) e).a;
   else throw error(err._1());
 }