Hi Stephen,
you may right :)

First note that the Enum values are used as an ephemeral state, the serialized 
form still uses an integer as the original code.
You can also note that the enum is not loaded if no immutable collection is 
serialized (because CollSer is not initialized).
It's just a good old OOP trick that transforms a switch to a dispatch that will 
be used when de-serializing.

In my opinion, if there are several other immutable collections (like the 
ordered set/map proposed by Stuart), the code with an enum is easier to modify 
that the current code, otherwise, as you said, it's an overkill.

Rémi

----- Mail original -----
> De: "Stephen Colebourne" <scolebou...@joda.org>
> À: "core-libs-dev" <core-libs-dev@openjdk.java.net>
> Envoyé: Lundi 9 Mai 2016 19:49:15
> Objet: Re: RFR(m): 8139233u1 add initial compact immutable collection 
> implementations
> 
> On 9 May 2016 at 15:25, Remi Forax <fo...@univ-mlv.fr> wrote:
> >   CollSer implementation can be improved to avoid the ugly switch/case by
> >   replacing the constant list by an enum,
> 
> CollSer is modelled on JSR-310 code which uses an int. An enum would
> be a huge overkill for this use case.
> 
> Stephen
> 

Reply via email to