/** * Unsubscribe to a topic * * @param topicId * @return */ public boolean unsubscribe(EventTopic et) { if (!eventTopicIds.contains(et.getId())) { return false; } eventTopicIds.remove(et.getId()); // et.subscribersCount--; update(); return true; }
/** * Subscribe to a topic * * @param et * @return */ public boolean subscribe(EventTopic et) { if (eventTopicIds.contains(et.getId())) { return false; } eventTopicIds.add(et.getId()); Collections.sort(eventTopicIds); et.subscribersCount++; update(); return true; }