Compares two event classes based on their position in a class hierarchy. Classes higher up in a hierarchy are
'greater than' (ordered later) than classes lower in a hierarchy (ordered earlier). Classes in unrelated
hierarchies have the same order priority.
Event bus implementations use this comparator to determine which event listener method to invoke when polymorphic
listener methods are defined:
If two event classes exist A and B, where A is the parent class of B (and B is a subclass of A) and an event
subscriber listens to both events:
@Subscribe
public void onEvent(A a) { ... }
@Subscribe
public void onEvent(B b) { ... }
The
onEvent(B b) method will be invoked on the subscriber and the
onEvent(A a) method will
not be invoked. This is to prevent multiple dispatching of a single event
to the same consumer.
The EventClassComparator is used to order listener method priority based on their event argument class - methods
handling event subclasses have higher precedence than superclasses.