All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bidib.wizard.common.node.PortsChangeWrapper Maven / Gradle / Ivy

package org.bidib.wizard.common.node;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.bidib.wizard.api.model.NodeInterface;
import org.bidib.wizard.api.model.listener.PortListener;
import org.bidib.wizard.api.model.listener.PortStatusListener;
import org.bidib.wizard.api.model.listener.PortValueListener;
import org.bidib.wizard.model.ports.Port;
import org.bidib.wizard.model.status.BidibStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PortsChangeWrapper {

    private static final Logger LOGGER = LoggerFactory.getLogger(PortsChangeWrapper.class);

    public static 

, S extends BidibStatus> void notifyPortConfigChanged( final List> listeners, final NodeInterface node, final P port) { final List> safeListeners = Collections.checkedList((List) listeners, PortListener.class); for (PortListener

l : safeListeners) { LOGGER.info("Notify changed port config to listener: {}", l); l.configChanged(node, port); } } public static

, S extends BidibStatus> void notifyPortStatusChanged( final Collection> listeners, final NodeInterface node, final P port) { final List> safeListeners = new ArrayList<>(); for (PortListener listener : listeners) { if (listener instanceof PortStatusListener) { safeListeners.add((PortStatusListener) listener); } } LOGGER.info("notifyPortStatusChanged, port: {}, safeListeners: {}", port, safeListeners); for (PortStatusListener

l : safeListeners) { LOGGER.info("Notify changed port status to listener: {}", l); l.statusChanged(node, port); } } public static

, S extends BidibStatus> void notifyPortValueChanged( final Collection> listeners, final NodeInterface node, final P port) { final Collection> safeListeners = new ArrayList<>(); for (PortListener listener : listeners) { if (listener instanceof PortValueListener) { safeListeners.add((PortValueListener) listener); } } LOGGER.info("notifyPortValueChanged, port: {}, safeListeners: {}", port, safeListeners); for (PortValueListener

l : safeListeners) { LOGGER.info("Notify port value listener: {}", l); l.valueChanged(node, port); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy