package net.onrc.onos.core.topology;

/**
 * Self-contained Topology event Object
 * <p/>
 * TODO: For now the topology event contains one of the following events:
 * Switch, Port, Link, Host. In the future it will contain multiple events
 * in a single transaction.
 */
public class TopologyEvent {
    SwitchEvent switchEvent = null;        // Set for Switch event
    PortEvent portEvent = null;            // Set for Port event
    LinkEvent linkEvent = null;            // Set for Link event
    HostEvent hostEvent = null;        // Set for Host event

    /**
     * Default constructor.
     */
    public TopologyEvent() {
    }

    /**
     * Constructor for given Switch event.
     *
     * @param switchEvent the Switch event to use.
     */
    TopologyEvent(SwitchEvent switchEvent) {
        this.switchEvent = switchEvent;
    }

    /**
     * Constructor for given Port event.
     *
     * @param portEvent the Port event to use.
     */
    TopologyEvent(PortEvent portEvent) {
        this.portEvent = portEvent;
    }

    /**
     * Constructor for given Link event.
     *
     * @param linkEvent the Link event to use.
     */
    TopologyEvent(LinkEvent linkEvent) {
        this.linkEvent = linkEvent;
    }

    /**
     * Constructor for given Host event.
     *
     * @param hostEvent the Host event to use.
     */
    TopologyEvent(HostEvent hostEvent) {
        this.hostEvent = hostEvent;
    }

    /**
     * Get the string representation of the event.
     *
     * @return the string representation of the event.
     */
    @Override
    public String toString() {
        if (switchEvent != null) {
            return switchEvent.toString();
        }
        if (portEvent != null) {
            return portEvent.toString();
        }
        if (linkEvent != null) {
            return linkEvent.toString();
        }
        if (hostEvent != null) {
            return hostEvent.toString();
        }
        return "[Empty TopologyEvent]";
    }

    /**
     * Get the Topology event ID.
     *
     * @return the Topology event ID.
     */
    public byte[] getID() {
        if (switchEvent != null) {
            return switchEvent.getID();
        }
        if (portEvent != null) {
            return portEvent.getID();
        }
        if (linkEvent != null) {
            return linkEvent.getID();
        }
        if (hostEvent != null) {
            return hostEvent.getID();
        }
        return null;
    }
}

@@ -31,16 +31,44 @@
 ology;%0A%0A
+import java.util.Objects;%0A%0A%0A
 /**%0A * S
@@ -1446,32 +1446,811 @@
 stEvent;%0A    %7D%0A%0A
+    /**%0A     * Check if all events contained are equal.%0A     * @param object.%0A     */%0A    @Override%0A    public boolean equals(Object obj) %7B%0A        if (this == obj) %7B%0A            return true;%0A        %7D%0A%0A        if (obj == null) %7B%0A            return false;%0A        %7D%0A%0A        if (getClass() != obj.getClass()) %7B%0A            return false;%0A        %7D%0A%0A        TopologyEvent other = (TopologyEvent) obj;%0A        return Objects.equals(switchEvent, other.switchEvent) &&%0A                Objects.equals(portEvent, other.portEvent) &&%0A                Objects.equals(linkEvent, other.linkEvent) &&%0A                Objects.equals(hostEvent, other.hostEvent);%0A    %7D%0A%0A    @Override%0A    public int hashCode() %7B%0A        return Objects.hash(switchEvent, portEvent, linkEvent, hostEvent);%0A    %7D%0A%0A
     /**%0A     * G

Add the equals function