public DefaultPrimaryElection(PartitionId partitionId, SessionClient proxy, PrimaryElectionService service) { this.partitionId = checkNotNull(partitionId); this.proxy = proxy; this.service = service; this.eventListener = event -> { if (event.partitionId().equals(partitionId)) { listeners.forEach(l -> l.event(event)); } }; service.addListener(eventListener); }