blob: afc2af3946d480a05b4b9b58e194d19b80ace69e [file] [log] [blame]
HIGUCHI Yuta356086e2013-06-12 15:21:19 -07001package net.onrc.onos.ofcontroller.util;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08002
HIGUCHI Yuta356086e2013-06-12 15:21:19 -07003import net.onrc.onos.ofcontroller.util.Port;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08004
5import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08006
7/**
8 * The class representing a Switch-Port.
9 */
10public class SwitchPort {
11 private Dpid dpid; // The DPID of the switch
12 private Port port; // The port of the switch
13
14 /**
15 * Default constructor.
16 */
17 public SwitchPort() {
18 }
19
20 /**
21 * Constructor for a given DPID and a port.
22 *
23 * @param dpid the DPID to use.
24 * @param port the port to use.
25 */
26 public SwitchPort(Dpid dpid, Port port) {
27 this.dpid = dpid;
28 this.port = port;
29 }
30
31 /**
32 * Get the DPID value of the Switch-Port.
33 *
34 * @return the DPID value of the Switch-Port.
35 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080036 @JsonProperty("dpid")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080037 public Dpid dpid() { return dpid; }
38
39 /**
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080040 * Set the DPID value of the Switch-Port.
41 *
42 * @param dpid the DPID to use.
43 */
44 @JsonProperty("dpid")
45 public void setDpid(Dpid dpid) {
46 this.dpid = dpid;
47 }
48
49 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080050 * Get the port value of the Switch-Port.
51 *
52 * @return the port value of the Switch-Port.
53 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080054 @JsonProperty("port")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080055 public Port port() { return port; }
56
57 /**
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080058 * Set the port value of the Switch-Port.
59 *
60 * @param port the port to use.
61 */
62 @JsonProperty("port")
63 public void setPort(Port port) {
64 this.port = port;
65 }
66
67 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080068 * Set the DPID and port values of the Switch-Port.
69 *
70 * @param dpid the DPID to use.
71 * @param port the port to use.
72 */
73 public void setValue(Dpid dpid, Port port) {
74 this.dpid = dpid;
75 this.port = port;
76 }
77
78 /**
79 * Convert the Switch-Port value to a string.
80 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080081 * The string has the following form:
82 * 01:02:03:04:05:06:07:08/1234
83 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080084 * @return the Switch-Port value as a string.
85 */
86 @Override
87 public String toString() {
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080088 return this.dpid.toString() + "/" + this.port;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080089 }
90}