87e30d70c61ebcc2e1fffe0c376a1b146d8ab561
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / core / internal / SwitchEvent.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.protocol_plugin.openflow.core.internal;
11
12 import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
13 import org.openflow.protocol.OFMessage;
14
15 public class SwitchEvent {
16
17     public static enum SwitchEventType {
18         SWITCH_ADD, SWITCH_DELETE, SWITCH_ERROR, SWITCH_MESSAGE,
19     }
20
21     private SwitchEventType eventType;
22     private ISwitch sw;
23     private OFMessage msg;
24
25     public SwitchEvent(SwitchEventType type, ISwitch sw, OFMessage msg) {
26         this.eventType = type;
27         this.sw = sw;
28         this.msg = msg;
29     }
30
31     public SwitchEventType getEventType() {
32         return this.eventType;
33     }
34
35     public ISwitch getSwitch() {
36         return this.sw;
37     }
38
39     public OFMessage getMsg() {
40         return this.msg;
41     }
42
43     @Override
44     public String toString() {
45         String s;
46         switch (this.eventType) {
47         case SWITCH_ADD:
48             s = "SWITCH_ADD";
49             break;
50         case SWITCH_DELETE:
51             s = "SWITCH_DELETE";
52             break;
53         case SWITCH_ERROR:
54             s = "SWITCH_ERROR";
55             break;
56         case SWITCH_MESSAGE:
57             s = "SWITCH_MESSAGE";
58             break;
59         default:
60             s = "?" + this.eventType.ordinal() + "?";
61         }
62         return "Switch Event: " + s;
63     }
64 }