Sonar clean-up: braces for control statements
[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         }
76         if (obj == null) {
77             return false;
78         }
79         if (getClass() != obj.getClass()) {
80             return false;
81         }
82         AbstractEvent other = (AbstractEvent) obj;
83         if (handlerType == null) {
84             if (other.handlerType != null) {
85                 return false;
86             }
87         } else if (!handlerType.equals(other.handlerType)) {
88             return false;
89         }
90         if (action == null) {
91             if (other.action != null) {
92                 return false;
93             }
94         } else if (!action.equals(other.action)) {
95             return false;
96         }
97         return true;
98     }
99 }