Class Eithers

java.lang.Object
ca.uhn.fhir.util.monad.Eithers

public class Eithers extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static <L, R> Either<L,R>
    for2(L left, R right)
    Creates an Either instance from two values.
    static <L, M, R> Either3<L,M,R>
    for3(L left, M middle, R right)
    Creates an Either3 instance from three values.
    static <L, R> Either<L,R>
    forLeft(L left)
    Creates an Either instance from a left value.
    static <L, M, R> Either3<L,M,R>
    forLeft3(L left)
    Creates an Either3 instance from a left value.
    static <L, M, R> Either3<L,M,R>
    forMiddle3(M middle)
    Creates an Either3 instance from a middle value.
    static <L, R> Either<L,R>
    forRight(R right)
    Creates an Either instance from a right value.
    static <L, M, R> Either3<L,M,R>
    forRight3(R right)
    Creates an Either3 instance from a right value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • for2

      public static <L, R> Either<L,R> for2(L left, R right)
      Creates an Either instance from two values. If the left value is not null, the Either will be left. Otherwise, it will be right. Exactly one of the values must be present.
      Type Parameters:
      L - the left type
      R - the right type
      Parameters:
      left - the left value
      right - the right value
      Returns:
      an Either instance containing either left or right value
    • forLeft

      public static <L, R> Either<L,R> forLeft(L left)
      Creates an Either instance from a left value. Left cannot be null.
      Type Parameters:
      L - the left type
      R - the right type
      Parameters:
      left - the left value
      Returns:
      an Either instance containing the left value
    • forRight

      public static <L, R> Either<L,R> forRight(R right)
      Creates an Either instance from a right value. Right cannot be null.
      Type Parameters:
      L - the left type
      R - the right type
      Parameters:
      right - the right value
      Returns:
      an Either instance containing the right value
    • for3

      public static <L, M, R> Either3<L,M,R> for3(L left, M middle, R right)
      Creates an Either3 instance from three values. If the left value is not null, the Either3 will be left. If the middle value is not null, the Either3 will be middle. Otherwise, it will be right. Exactly of the values must be present.
      Type Parameters:
      L - the left type
      M - the middle type
      R - the right type
      Parameters:
      left - the left value
      middle - the middle value
      right - the right value
      Returns:
      the Either3 instance containing either left, middle, or right value
    • forLeft3

      public static <L, M, R> Either3<L,M,R> forLeft3(L left)
      Creates an Either3 instance from a left value. Left cannot be null.
      Type Parameters:
      L - the left type
      M - the middle type
      R - the right type
      Parameters:
      left - the left value
      Returns:
      the Either3 instance containing the left value
    • forMiddle3

      public static <L, M, R> Either3<L,M,R> forMiddle3(M middle)
      Creates an Either3 instance from a middle value. Middle cannot be null.
      Type Parameters:
      L - the left type
      M - the middle type
      R - the right type
      Parameters:
      middle - the middle value
      Returns:
      the Either3 instance containing the middle value
    • forRight3

      public static <L, M, R> Either3<L,M,R> forRight3(R right)
      Creates an Either3 instance from a right value. Right cannot be null.
      Type Parameters:
      L - the left type
      M - the middle type
      R - the right type
      Parameters:
      right - the right value
      Returns:
      the Either3 instance containing the right value