Merge "Revert "Added controller is-connected code""
[ovsdb.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
20     public enum HandlerType {
21         SOUTHBOUND,
22         NEUTRON_FLOATING_IP,
23         NEUTRON_NETWORK,
24         NEUTRON_PORT,
25         NEUTRON_PORT_SECURITY,
26         NEUTRON_ROUTER,
27         NEUTRON_SUBNET,
28         NEUTRON_FWAAS,
29         NEUTRON_LOAD_BALANCER,
30         NEUTRON_LOAD_BALANCER_POOL,
31         NEUTRON_LOAD_BALANCER_POOL_MEMBER,
32         NODE;
33
34         public static final int size = HandlerType.values().length;
35     }
36
37     private HandlerType handlerType;
38     private Action action;
39
40     private AbstractEvent() {
41         // this is private to force proper construction
42     }
43
44     protected AbstractEvent(HandlerType handlerType, Action action) {
45         this.handlerType = handlerType;
46         this.action = action;
47     }
48
49     public HandlerType getHandlerType() {
50         return handlerType;
51     }
52
53     public Action getAction() {
54         return action;
55     }
56
57     @Override
58     public String toString() {
59         return "AbstractEvent [handlerType=" + handlerType + " action=" + action + "]";
60     }
61
62     @Override
63     public int hashCode() {
64         final int prime = 31;
65         int result = 1;
66         result = prime * result + ((handlerType == null) ? 0 : handlerType.hashCode());
67         result = prime * result + ((action == null) ? 0 : action.hashCode());
68         return result;
69     }
70
71     @Override
72     public boolean equals(Object obj) {
73         if (this == obj)
74             return true;
75         if (obj == null)
76             return false;
77         if (getClass() != obj.getClass())
78             return false;
79         AbstractEvent other = (AbstractEvent) obj;
80         if (handlerType == null) {
81             if (other.handlerType != null)
82                 return false;
83         } else if (!handlerType.equals(other.handlerType))
84             return false;
85         if (action == null) {
86             if (other.action != null)
87                 return false;
88         } else if (!action.equals(other.action))
89             return false;
90         return true;
91     }
92 }