Is there a version of either java.beans.PropertyChangeSupport
or com.jgoodies.binding.beans.ExtendedPropertyChangeSupport
which is helpful for supporting change listeners along the lines of a Map or EnumMap? (a key-value store with known limited keys and change listeners for all the values in the map)
I don't really need beans-type access, I have a number of different statistics sort of like:
interface hasName() {
public String getName();
}
enum StatisticType implements hasName {
MILES_DRIVEN, BURGERS_SERVED, CUSTOMERS_HELPED, BIRDS_WATCHED;
@Override public String getName() { return name(); }
}
where I want to publish an interface like:
interface KeyValueStore<K extends hasName,V>
{
void setValue(K key, V value);
V getValue(K key);
void addPropertyChangeListener(PropertyChangeListener listener);
void removePropertyChangeListener(PropertyChangeListener listener);
/*
* when setValue() is called, this should send PropertyChangeEvents
* to all listeners, with the property name of K.getName()
*/
}
so I could use a KeyValueStore<StatisticType, Integer>
in my application.
Is there any convenient way to do this? My head is spinning around in circles and it's sapping my energy trying to reinvent the wheel on this stuff.