Provide FlowCapableNodeDataChangeListener to openstack.netvirt via NodeCacheManager
[netvirt.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / AbstractEvent.java
1 /*
2  * Copyright (C) 2014 Red Hat, Inc.
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  * Authors : Dave Tucker, Flavio Fernandes
9  */
10
11 package org.opendaylight.ovsdb.openstack.netvirt;
12
13 import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
14
15 /**
16  * Abstract class for events used by neutron northbound and southbound events.
17  */
18 public abstract class AbstractEvent {
19     public enum HandlerType {
20         SOUTHBOUND,
21         NEUTRON_FLOATING_IP,
22         NEUTRON_NETWORK,
23         NEUTRON_PORT,
24         NEUTRON_PORT_SECURITY,
25         NEUTRON_ROUTER,
26         NEUTRON_SUBNET,
27         NEUTRON_FWAAS,
28         NEUTRON_LOAD_BALANCER,
29         NEUTRON_LOAD_BALANCER_POOL,
30         NEUTRON_LOAD_BALANCER_POOL_MEMBER,
31         NODE;
32
33         public static final int size = HandlerType.values().length;
34     }
35
36     private HandlerType handlerType;
37     private Action action;
38
39     private AbstractEvent() {
40         // this is private to force proper construction
41     }
42
43     protected AbstractEvent(HandlerType handlerType, Action action) {
44         this.handlerType = handlerType;
45         this.action = action;
46     }
47
48     public HandlerType getHandlerType() {
49         return handlerType;
50     }
51
52     public Action getAction() {
53         return action;
54     }
55
56     @Override
57     public String toString() {
58         return "AbstractEvent [handlerType=" + handlerType + " action=" + action + "]";
59     }
60
61     @Override
62     public int hashCode() {
63         final int prime = 31;
64         int result = 1;
65         result = prime * result + ((handlerType == null) ? 0 : handlerType.hashCode());
66         result = prime * result + ((action == null) ? 0 : action.hashCode());
67         return result;
68     }
69
70     @Override
71     public boolean equals(Object obj) {
72         if (this == obj)
73             return true;
74         if (obj == null)
75             return false;
76         if (getClass() != obj.getClass())
77             return false;
78         AbstractEvent other = (AbstractEvent) obj;
79         if (handlerType == null) {
80             if (other.handlerType != null)
81                 return false;
82         } else if (!handlerType.equals(other.handlerType))
83             return false;
84         if (action == null) {
85             if (other.action != null)
86                 return false;
87         } else if (!action.equals(other.action))
88             return false;
89         return true;
90     }
91 }