class ConfigurableUDPSource {

    public static void setNotificationHandler(UDPNotificationHandler handler, String sourceName, Map incoming) {
        log.trace("Setting Notification handler for '{}'", sourceName);
        notificationHandlers.put(sourceName, handler);

        List<InetAddress> addresses = null;
        List<Integer> ports = null;
        List<List> servers = null;

        // Obtain all valid addresses, ports, and servers from the respective arrays specified in the configuration document
        if (incoming != null) {
            if (incoming.get("receiveAddresses") instanceof List) {
                addresses = getValidInetAddresses((List) incoming.get("receiveAddresses"), sourceName);
            }
            if (incoming.get("receivePorts") instanceof List) {
                ports = getValidPorts((List) incoming.get("receivePorts"));
            }
            if (incoming.get("receiveServers") instanceof List) {
                servers = getValidServers((List) incoming.get("receiveServers"));
            }
        }

        // Use the addresses specified
        if (addresses != null) {
            sourceAddresses.put(sourceName, addresses);
            log.debug("Source '{}' listening for addresses {}", sourceName, addresses);
        }
        // We should ignore all addresses only if there are requested servers and no valid settings for addresses or ports
        else if (servers != null && !valueIsTrue(incoming, "receiveAllAddresses")
                && !valueIsTrue(incoming, "receiveAllPorts") && ports == null) {
            sourceAddresses.put(sourceName, NO_ADDR);
        }
        // Either receiveAllAddresses is set to true with no addresses specified
        // or the settings allow defaulting to all addresses
        else {
            sourceAddresses.put(sourceName, ALL_ADDR);
            log.debug("Source '{}' listening for all addresses", sourceName);
        }

        // Use the ports if specified
        if (ports != null) {
            sourcePorts.put(sourceName, ports);
            log.debug("Source '{}' listening on ports {}", sourceName, ports);
        }
        // We should ignore all ports only if there are requested servers and no valid settings for addresses or ports
        else if (servers != null && !valueIsTrue(incoming, "receiveAllAddresses")
                && !valueIsTrue(incoming, "receiveAllPorts") && addresses == null) {
            sourcePorts.put(sourceName, NO_PORTS);
        }
        // Either receiveAllPorts is set to true with no ports specified or the settings allow defaulting to all ports
        else {
            sourcePorts.put(sourceName, ALL_PORTS);
            log.debug("Source '{}' listening on all ports", sourceName);
        }

        // Use the servers specified
        if (servers != null) {
            sourceServers.put(sourceName, servers);
        }
    }

}