Add support for openflow node callbacks
[ovsdb.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / NodeCacheManagerEvent.java
1 /*
2  * Copyright (c) 2015 Red Hat, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.ovsdb.openstack.netvirt;
9
10 import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
11 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
12
13 /**
14  * @author Flavio Fernandes (ffernand@redhat.com)
15  * @author Sam Hague (shague@redhat.com)
16  */
17 public class NodeCacheManagerEvent extends AbstractEvent {
18     private Node node;
19
20     public NodeCacheManagerEvent(Node node, Action action) {
21         super(HandlerType.NODE, action);
22         this.node = node;
23     }
24
25     public Node getNode() {
26         return node;
27     }
28
29     public String getNodeIdentifier() {
30         return node.getNodeId().getValue();
31     }
32
33     @Override
34     public String toString() {
35         return "NodeCacheManagerEvent [action=" + super.getAction()
36                + ", node=" + node
37                + "]";
38     }
39
40     @Override
41     public int hashCode() {
42         final int prime = 31;
43         int result = super.hashCode();
44         result = prime * result + ((node == null) ? 0 : node.hashCode());
45         return result;
46     }
47
48     @Override
49     public boolean equals(Object obj) {
50         if (this == obj) {
51             return true;
52         }
53         if (obj == null) {
54             return false;
55         }
56         if (getClass() != obj.getClass()) {
57             return false;
58         }
59         if (!super.equals(obj)) {
60             return false;
61         }
62         NodeCacheManagerEvent other = (NodeCacheManagerEvent) obj;
63         if (node == null) {
64             if (other.node != null) {
65                 return false;
66             }
67         } else if (!node.equals(other.node)) {
68             return false;
69         }
70         return true;
71     }
72 }