Just like java.util.Optional
in Java 8 is (somewhat) equivalent to Scala\'s Option[T]
type, is there an equivalent to Scala\'s Eithe
There is no Either in the Java Standard Library. However there is an implementation of Either in FunctionalJava, along with many other nice classes.
No, there is none.
Java language developers explicitly state that types like Option<T>
are intended to be used only as temporary values (e.g. in stream operations results), so while they are the same thing as in other languages, they are not supposed to be used as they are used in other languages. So it is not surprising that there is no such thing as Either
because it does not arise naturally (e.g. from stream operations) like Optional
does.