Class Either<L,R>

java.lang.Object
org.ehrbase.openehr.sdk.util.functional.Either<L,R>
Direct Known Subclasses:
Either.Left, Either.Right, Try

public abstract class Either<L,R> extends Object
  • Field Details

    • value

      protected final Object value
  • Constructor Details

    • Either

      protected Either(Object value)
  • Method Details

    • left

      public static <L1, R1> Either.Left<L1,R1> left(L1 value)
    • right

      public static <L1, R1> Either.Right<L1,R1> right(R1 value)
    • isLeft

      public abstract boolean isLeft()
    • isRight

      public abstract boolean isRight()
    • get

      public abstract Object get()
    • getAsLeft

      public abstract L getAsLeft()
    • getAsRight

      public abstract R getAsRight()
    • map

      public abstract <T> T map(BiFunction<L,R,T> map)
      Convenience method to transform the internal state
      Parameters:
      map - function which maps the internal state to the specified type The function must be null safe in both arguments
      Returns:
      the mapped internal state
    • consume

      public abstract void consume(BiConsumer<L,R> con)
      Convenience method to consume the internal state
      Parameters:
      con - consumer which consumes the internal state The consumer must be null safe in both arguments