
Package ca.uhn.fhir.util.monad
Class Eithers
java.lang.Object
ca.uhn.fhir.util.monad.Eithers
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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.
-
Method Details
-
for2
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 typeR
- the right type- Parameters:
left
- the left valueright
- the right value- Returns:
- an Either instance containing either left or right value
-
forLeft
Creates an Either instance from a left value. Left cannot be null.- Type Parameters:
L
- the left typeR
- the right type- Parameters:
left
- the left value- Returns:
- an Either instance containing the left value
-
forRight
Creates an Either instance from a right value. Right cannot be null.- Type Parameters:
L
- the left typeR
- the right type- Parameters:
right
- the right value- Returns:
- an Either instance containing the right value
-
for3
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 typeM
- the middle typeR
- the right type- Parameters:
left
- the left valuemiddle
- the middle valueright
- the right value- Returns:
- the Either3 instance containing either left, middle, or right value
-
forLeft3
Creates an Either3 instance from a left value. Left cannot be null.- Type Parameters:
L
- the left typeM
- the middle typeR
- the right type- Parameters:
left
- the left value- Returns:
- the Either3 instance containing the left value
-
forMiddle3
Creates an Either3 instance from a middle value. Middle cannot be null.- Type Parameters:
L
- the left typeM
- the middle typeR
- the right type- Parameters:
middle
- the middle value- Returns:
- the Either3 instance containing the middle value
-
forRight3
Creates an Either3 instance from a right value. Right cannot be null.- Type Parameters:
L
- the left typeM
- the middle typeR
- the right type- Parameters:
right
- the right value- Returns:
- the Either3 instance containing the right value
-