Re: Subclassing EnumSet to add an interface?
- From: Patricia Shanahan <pats@xxxxxxx>
- Date: Tue, 15 May 2007 09:17:47 GMT
Eric Smith wrote:
....
My point was that it seemed unreasonable for Java to deny me the
ability to extend an EnumSet to add a small amount of new behavior.
I can live with the fact that I can't do it, but no one has offered
justification as to why such a limitation was a reasonable design
choice. The fact there are other ways to do something isn't a
good justification for introducing non-orthonality into a design.
Eric
I think the real issue is the decision to use public static factory
methods in class EnumSet rather than having a public constructor.
The factory approach allows the base class to choose the actual class of
the object at run time, based on the parameters. A public constructor
leaves the actual class in the hands of the caller, through subclassing.
Looking at its source code, EnumSet does take advantage of having
control over the subclass. It uses different implementations depending
on whether the Enum has no more than 64 elements. The RegularEnumSet
implementation takes advantage of the bits fitting in a single long.
JumboEnumSet uses an array of long.
Patricia
.
- References:
- Subclassing EnumSet to add an interface?
- From: Eric Smith
- Re: Subclassing EnumSet to add an interface?
- From: Mike Schilling
- Re: Subclassing EnumSet to add an interface?
- From: Eric Smith
- Re: Subclassing EnumSet to add an interface?
- From: Tom Hawtin
- Re: Subclassing EnumSet to add an interface?
- From: Eric Smith
- Re: Subclassing EnumSet to add an interface?
- From: Lew
- Re: Subclassing EnumSet to add an interface?
- From: Eric Smith
- Re: Subclassing EnumSet to add an interface?
- From: Tom Hawtin
- Re: Subclassing EnumSet to add an interface?
- From: Eric Smith
- Subclassing EnumSet to add an interface?
- Prev by Date: do something every 1000 records or so
- Next by Date: Re: EXE without JVM
- Previous by thread: Re: Subclassing EnumSet to add an interface?
- Next by thread: Re: Subclassing EnumSet to add an interface?
- Index(es):