class EnvoyCoupler {

    public List<WMSEnvoyAndState> retrieveRelatedEnvoys(Collection<? extends WMSLayerState> states)
    {
        List<WMSEnvoyAndState> envoyAndStates = New.list();

        Map<String, WMSEnvoy> serversAndEnvoys = mapServersAndEnvoys();
        Set<String> retrievedTypes = New.set();
        Set<String> notLoadedServers = New.set();

        for (WMSLayerState state : states)
        {
            WMSEnvoy envoy = serversAndEnvoys.get(state.getUrl());

            if (envoy != null)
            {
                String[] layerNames = state.getParameters().getLayerName().split(",");
                for (String layerName : layerNames)
                {
                    String key = WMSLayerKey.createKey(
                            envoy.getServerConnectionConfig().getServerId(OGCServerSource.WMS_GETMAP_SERVICE), layerName);

                    if (!retrievedTypes.contains(key))
                    {
                        DataTypeInfo existingType = myDataController.findMemberById(key);

                        if (existingType instanceof WMSDataType)
                        {
                            retrievedTypes.add(key);
                            WMSDataType existingWmsType = (WMSDataType)existingType;
                            WMSEnvoyAndState envoyAndState = new WMSEnvoyAndState(envoy, existingWmsType, state, layerName);
                            envoyAndStates.add(envoyAndState);
                        }
                        else
                        {
                            String message = "Unable to restore WMS layer " + state.getId() + " layer does not exist on server "
                                    + state.getUrl();
                            LOGGER.warn(message);
                            Notify.warn(message);
                        }
                    }
                }
            }
            else
            {
                notLoadedServers.add(state.getUrl());
            }
        }

        for (String notLoadedServer : notLoadedServers)
        {
            LOGGER.warn("Server not loaded unable to load any WMS layers for " + notLoadedServer);
        }

        return envoyAndStates;
    }

    public  EnvoyCoupler(Plugin wmsPlugin, GenericRegistry<Envoy> envoyRegistry, DataGroupController dataController);

}