blob: 027b6812219de7e11c54ebc8f57f070674cbd27d [file] [log] [blame]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08001package net.floodlightcontroller.util;
2
3import net.floodlightcontroller.util.Dpid;
4import net.floodlightcontroller.util.Port;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08005
6import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08007
8/**
9 * The class representing a Switch-Port.
10 */
11public class SwitchPort {
12 private Dpid dpid; // The DPID of the switch
13 private Port port; // The port of the switch
14
15 /**
16 * Default constructor.
17 */
18 public SwitchPort() {
19 }
20
21 /**
22 * Constructor for a given DPID and a port.
23 *
24 * @param dpid the DPID to use.
25 * @param port the port to use.
26 */
27 public SwitchPort(Dpid dpid, Port port) {
28 this.dpid = dpid;
29 this.port = port;
30 }
31
32 /**
33 * Get the DPID value of the Switch-Port.
34 *
35 * @return the DPID value of the Switch-Port.
36 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080037 @JsonProperty("dpid")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080038 public Dpid dpid() { return dpid; }
39
40 /**
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080041 * Set the DPID value of the Switch-Port.
42 *
43 * @param dpid the DPID to use.
44 */
45 @JsonProperty("dpid")
46 public void setDpid(Dpid dpid) {
47 this.dpid = dpid;
48 }
49
50 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080051 * Get the port value of the Switch-Port.
52 *
53 * @return the port value of the Switch-Port.
54 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080055 @JsonProperty("port")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080056 public Port port() { return port; }
57
58 /**
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080059 * Set the port value of the Switch-Port.
60 *
61 * @param port the port to use.
62 */
63 @JsonProperty("port")
64 public void setPort(Port port) {
65 this.port = port;
66 }
67
68 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080069 * Set the DPID and port values of the Switch-Port.
70 *
71 * @param dpid the DPID to use.
72 * @param port the port to use.
73 */
74 public void setValue(Dpid dpid, Port port) {
75 this.dpid = dpid;
76 this.port = port;
77 }
78
79 /**
80 * Convert the Switch-Port value to a string.
81 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080082 * The string has the following form:
83 * 01:02:03:04:05:06:07:08/1234
84 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080085 * @return the Switch-Port value as a string.
86 */
87 @Override
88 public String toString() {
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080089 return this.dpid.toString() + "/" + this.port;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080090 }
91}