Roedy Green <> writes:
> The other option is to provide a classic bitmap interface, rather than
> an EnumSet for my Windows attribute get/setter.
Another option is to encapsulate the data and just provide methods, e.g.,
boolean isArchived()
boolean isReadOnly()
boolean isDirectory()
boolean isHidden()
etc.
The fact that these are in some ways stored in a number is an implementation
detail that need not be exposed.
If you really want an enum representing capabilities, you can make
one that works on these:
enum FileCapability {
CAN_READ {
public boolean isAllowed(RGFile file) {
return file.isAllowed();
}
},
// ...
;
public abstract boolean isAllowed(RGFile file);
}
You can the build an EnumSet only when you need it for something, using
EnumSet<FileCapability> getCapabilties();
You can cache it in a transient field to avoid recreating.
/L
--
Lasse Reichstein Nielsen -
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'