code: private Set<DistributedEvent> optimizeEvents(Set<DistributedEvent> distEvents) {
          Map<TriggerKey, Operation> map = new HashMap<>();
          distEvents.stream().forEach(event -> map.put(new TriggerKey(event.getTenantId(), event.getTriggerId()),
                  event.getOperation()));
          Set<DistributedEvent> optimizedEvents = new HashSet<>();
          map.entrySet().stream().forEach(entry -> optimizedEvents.add(new DistributedEvent(entry.getValue(),
                  entry.getKey().getTenantId(), entry.getKey().getTriggerId())));
          return optimizedEvents;
      }
docs: /*
  A refresh() call can be invoked with several events for same trigger
  (i.e. trigger creation, conditions added, trigger enabled, and trigger removed)
  Effectively the last event for the same trigger is what this extension needs to load/unload the trigger
  from the alerter/extension.