Did you know that you can do that?
private static enum DynamicProperty {
cacheManagerName {
@Override
void applyChange(final PropertyChangeEvent evt, final RuntimeCfg config) {
config.cacheManagerName = (String) evt.getNewValue();
}
},
defaultCacheConfiguration {
@Override
void applyChange(final PropertyChangeEvent evt, final RuntimeCfg config) {
LOG.debug("Default Cache Configuration has changed, previously created caches remain untouched");
}
};
abstract void applyChange(PropertyChangeEvent evt, RuntimeCfg config);
}
I think it’s nice because it allows you to customize Enum’s behavior or perform other actions on use.
Piece of code taken from EhCache Configuration (line 118 and further).
Couple of years ago I wasn't a big fan of unit testing. It was obvious to me that well prepared unit tests are crucial though. I didn't known why exactly crucial yet then. I just felt they are important. My disliking to write automation tests was mostly related to the effort necessary to prepare them. Also a spaghetti code was easily spotted in test sources.
