Class EitherUtils

java.lang.Object
com.atlassian.jira.util.EitherUtils

public final class EitherUtils extends Object
Utility functions for Eithers.
Since:
v6.4
  • Method Details

    • splitEithers

      public static <L, R> io.atlassian.fugue.Pair<List<L>,List<R>> splitEithers(Iterable<io.atlassian.fugue.Either<L,R>> eithers)
      Transforms list of Eithers into two lists, which contains left and right values.
    • unwrapEither

      public static <L extends RuntimeException, R> R unwrapEither(io.atlassian.fugue.Either<L,R> either)
      Gets the right value from an Either or throws its left value. Requires the left type to be a RuntimeException so that it can be used directly with higher-order functions like Optional.map(java.util.function.Function<? super T, ? extends U>) without needing to handle checked exceptions explicitly.
      Type Parameters:
      L - the left type of the either
      R - the right type of the either
      Parameters:
      either - the Either to unwrap
      Returns:
      the unwrapped right value
      Throws:
      L - if the either has a left value