class DefaultClientIdRegistry implements ClientIdRegistry {

    @Override
    public boolean register(String clientStreamId, String clientId, ConnectionType type) {
        Map<String, String> connectionTypeMap = clientIdMapPerType.computeIfAbsent(type,
                                                                                   t -> new ConcurrentHashMap<>());
        String prev = connectionTypeMap.put(clientStreamId, clientId);
        if (logger.isInfoEnabled()) {
            Set<String> streamSet = connectionTypeMap.entrySet()
                                                     .stream()
                                                     .filter(e -> e.getValue().equals(clientId))
                                                     .map(Map.Entry::getKey)
                                                     .collect(Collectors.toSet());
            if (streamSet.size() != 1) {
                logger.info("Multiple mappings for {} stream for clientId {}: {}", type, clientId, streamSet);
            }
        }
        return prev == null;
    }

}