{"action":"closed","issue":{"url":"https://api.github.com/repos/akka/akka/issues/25181","repository_url":"https://api.github.com/repos/akka/akka","labels_url":"https://api.github.com/repos/akka/akka/issues/25181/labels{/name}","comments_url":"https://api.github.com/repos/akka/akka/issues/25181/comments","events_url":"https://api.github.com/repos/akka/akka/issues/25181/events","html_url":"https://github.com/akka/akka/issues/25181","id":328418661,"node_id":"MDU6SXNzdWUzMjg0MTg2NjE=","number":25181,"title":"Add akka.japi.Either to Akka Java API helpers","user":{"login":"laszlovandenhoek","id":998449,"node_id":"MDQ6VXNlcjk5ODQ0OQ==","avatar_url":"https://avatars3.githubusercontent.com/u/998449?v=4","gravatar_id":"","url":"https://api.github.com/users/laszlovandenhoek","html_url":"https://github.com/laszlovandenhoek","followers_url":"https://api.github.com/users/laszlovandenhoek/followers","following_url":"https://api.github.com/users/laszlovandenhoek/following{/other_user}","gists_url":"https://api.github.com/users/laszlovandenhoek/gists{/gist_id}","starred_url":"https://api.github.com/users/laszlovandenhoek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laszlovandenhoek/subscriptions","organizations_url":"https://api.github.com/users/laszlovandenhoek/orgs","repos_url":"https://api.github.com/users/laszlovandenhoek/repos","events_url":"https://api.github.com/users/laszlovandenhoek/events{/privacy}","received_events_url":"https://api.github.com/users/laszlovandenhoek/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-06-01T07:59:58Z","updated_at":"2018-06-03T22:27:30Z","closed_at":"2018-06-03T22:27:30Z","author_association":"CONTRIBUTOR","body":"As far as I can tell, `scala.util.Either` is not used anywhere in the public Java API of core Akka (or Akka Streams). However, it _is_ used in akka-stream-contrib, particularly `PartitionWith`. Constructing a `scala.util.Either` from Java code is inconvenient; for example, `Either.cond` takes two by-name arguments but these are eagerly evaluated when called from Java, which often defeats the purpose of using `Either` at all.\r\n\r\nI came up with this bit to scratch that particular itch:\r\n\r\n```\r\nimport java.util.function.Supplier\r\n\r\nobject Either {\r\n  def cond[A, B](condition: Boolean,\r\n                 getB: Supplier[B],\r\n                 getA: Supplier[A]): scala.Either[A,B] = {\r\n    scala.Either.cond(condition, getB.get(), getA.get())\r\n  }\r\n}\r\n```\r\n...but I guess this is a bit light to include as a central library component as it stands. I think it could be a valuable addition, opening up new possibilities, but before fleshing it out and submitting a PR, I figured I'd open this issue as an RFC. In particular, I'm curious if the Akka team is open to adding an `Either` to the `akka.japi` package (in akka-actor), and if so, what features it should have and/or lack."}}
{"actor":{"display_login":"laszlovandenhoek"}}