I wonder if there is a bug in the Contact class from the axon-
addressbook-app example:
1) Method already removes the address:
public void removeAddress(AddressType type) {
if (addresses.remove(type) != null) {
apply(new AddressRemovedEvent(type));
}
}
2) Event handler method does the same again:
@EventHandler
protected void handleAddressRemovedEvent(AddressRemovedEvent event) {
addresses.remove(event.getType());
}
I thought the first type of aggregate root method should only checks
constraints and the second applies the change!? So the first method
should be something like this:
public void removeAddress(AddressType type) {
if (addresses.containsKey(type)) {
apply(new AddressRemovedEvent(type));
}
}