Why is FunctionListMap using identity to check values and not equals?
I have the following situation:
private final EventList<E> items = GlazedLists.threadSafeList(new BasicEventList<E>());
private final DisposableMap<Key, E> itemsLookup = GlazedLists.syncEventListToMap(this.items,
new FunctionList.Function<E, Key>() {
public Key evaluate(final E sourceValue) {
return getKey(sourceValue);
}
});
I get updates from an external database that say which object (by key) has changed or was removed.
The removal using the itemsLookup works. However the put() method uses an Identity compare to find the item to be replaced. This is of course not working, since I am loading a new Object (different identity but same key) from the database every time. The object with the same Key should be replaced by using the equals method. How could I achieve that?
So when an Update comes in I do an
itemsLookup.put(key, database.load(key)) which naturally throws an exception because the new Object is not found in the base list.
Thanks,
Phil