candlepin/candlepin — pull request #667 by cakofony (2014-07-31 17:03:07+00:00)
Title: Ckozak/event refactor fix

EventBuilder is more general:

eventFactory.getEventBuilder(Target.POOL, Type.MODIFIED)
.setOldEntity(old)
.setNewEntity(updated)
.buildEvent();

Pros:
* Easier to use
* We don't have to write/maintain methods for every event type
* More consistent event creation than writing individual methods
* If we're patching an existing object (like consumer) this makes it easy to take a snapshot of json before and after changes are made, without passing around half-baked event objects.

Cons:
* Doesn't enforce types
* ex: I can create a POOL event, and give it a Consumer object.
* We can keep a mapping of event target enum -> Class in order to enforce this (although not using real types, just throw exceptions if they're mismatched)
* that would be the result of programmer error though