JEP 269: Convenience Factory Methods for Collections
chris.hegarty at oracle.com
Wed Oct 7 10:10:16 UTC 2015
On 7 Oct 2015, at 10:30, Stephen Colebourne <scolebourne at joda.org> wrote:
> On 7 October 2015 at 01:13, Stuart Marks <stuart.marks at oracle.com> wrote:
>> My question is, is this enough of a problem that we should allow nulls in
>> these collections? I would prefer not to do this, but if there is evidence
>> that this would be a mistake, I'd like to hear it.
>> And if disallowing nulls will cause developers to create things like
>> Map<K,Optional<V>>, are we ok with that, and are developers ok with that?
> Given what we know now vs when the collections library ws created, I
> think it would be a mistake to allow nulls. Developers that
> desperately want null in there have other mechanisms to achieve that,
> not just Optional.
I agree with this. These are, after all, “just convenience” methods,
there are other ways if null is required. I do not see any
compelling reason for allowing null, given the type of use case
these methods are trying address, collections and maps with
small numbers of elements.
> I too would argue against Optional in collections,
> at least until value types exist, but thats a social discussion, not
> one that can be controlled.
More information about the core-libs-dev