class SignalFilter {

    @SuppressWarnings("squid:S3864")
    List<Target> filter(final Signal<?> signal) {
        return connection.getTargets().stream()
                .filter(t -> isTargetAuthorized(t, signal)) // this is cheaper, so check this first
                // count authorized targets
                .peek(authorizedTarget -> connectionMonitorRegistry.forOutboundDispatched(connection.getId(),
                        authorizedTarget.getAddress())
                        .success(signal))
                .filter(t -> isTargetSubscribedForTopic(t, signal))
                // count authorized + filtered targets
                .peek(filteredTarget -> connectionMonitorRegistry.forOutboundFiltered(connection.getId(),
                        filteredTarget.getAddress())
                        .success(signal))
                .collect(Collectors.toList());
    }

      SignalFilter(final Connection connection,
            final ConnectionMonitorRegistry<ConnectionMonitor> connectionMonitorRegistry);

}