Optional require(s) NonNull
alessiostalla at gmail.com
Tue Oct 30 06:32:23 PDT 2012
On Tue, Oct 30, 2012 at 2:16 PM, Roland Tepp <luolong at gmail.com> wrote:
> I was wondering, what is the rationale in implementing the Optional this
> particular way?
> (there is a thread on Java posse google group where various deficiencies of
> current implementation are discussed at some length:
> I myself would like to ask why have you not implemented it same way as most
> implementations of Optional I've seen have done it, by having two separate
> classes for Absent and Present values
> (I attached my take on the Optional implementation to this email).
> This addresses imho very nicely the usual conceptual difference between
> values that are present and those that are not.
> Only present values have get method, so there is no way to accidentally get
> from an absent value.
In Java there isn't any pattern matching construct, so such a design
would force users to write ugly code with instanceof's and type casts.
Some gratuitous spam:
http://ripple-project.org Ripple, social credit system
http://villages.cc Villages.cc, Ripple-powered community economy
http://common-lisp.net/project/armedbear ABCL, Common Lisp on the JVM
http://code.google.com/p/tapulli my current open source projects
http://www.manydesigns.com/ ManyDesigns Portofino, open source
model-driven Java web application framework
More information about the lambda-dev