2 * Copyright (c) 2014, 2016 Red Hat, Inc. and others. All rights reserved.
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
9 package org.opendaylight.netvirt.openstack.netvirt;
11 import org.opendaylight.netvirt.openstack.netvirt.api.Action;
14 * Abstract class for events used by neutron northbound and southbound events.
16 public abstract class AbstractEvent {
18 public enum HandlerType {
23 NEUTRON_PORT_SECURITY,
27 NEUTRON_LOAD_BALANCER,
28 NEUTRON_LOAD_BALANCER_POOL,
29 NEUTRON_LOAD_BALANCER_POOL_MEMBER,
32 DISTRIBUTED_ARP_SERVICE;
34 public static final int size = HandlerType.values().length;
37 private HandlerType handlerType;
38 private Action action;
39 private int transactionId;
41 public int getTransactionId() {
45 private static int txId = 0;
46 private static int incTxId() {
49 public static int getTxId() {
53 private AbstractEvent() {
54 // this is private to force proper construction
57 protected AbstractEvent(HandlerType handlerType, Action action) {
58 this.handlerType = handlerType;
60 this.transactionId = incTxId();
63 public HandlerType getHandlerType() {
67 public Action getAction() {
72 public String toString() {
73 return "AbstractEvent [transactionId=" + transactionId
74 + " handlerType=" + handlerType + " action=" + action + "]";
78 public int hashCode() {
81 result = prime * result + ((handlerType == null) ? 0 : handlerType.hashCode());
82 result = prime * result + ((action == null) ? 0 : action.hashCode());
87 public boolean equals(Object obj) {
94 if (getClass() != obj.getClass()) {
97 AbstractEvent other = (AbstractEvent) obj;
98 if (handlerType == null) {
99 if (other.handlerType != null) {
102 } else if (!handlerType.equals(other.handlerType)) {
105 if (action == null) {
106 if (other.action != null) {
109 } else if (!action.equals(other.action)) {