blob: 95a934f3e37550bc065bbb1996ba6f1e025a118e [file] [log] [blame]
HIGUCHI Yuta356086e2013-06-12 15:21:19 -07001package net.onrc.onos.ofcontroller.util;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08002
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08003import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08004
5/**
6 * The class representing a Switch-Port.
7 */
8public class SwitchPort {
9 private Dpid dpid; // The DPID of the switch
10 private Port port; // The port of the switch
11
12 /**
13 * Default constructor.
14 */
15 public SwitchPort() {
16 }
17
18 /**
19 * Constructor for a given DPID and a port.
20 *
21 * @param dpid the DPID to use.
22 * @param port the port to use.
23 */
24 public SwitchPort(Dpid dpid, Port port) {
25 this.dpid = dpid;
26 this.port = port;
27 }
28
29 /**
30 * Get the DPID value of the Switch-Port.
31 *
32 * @return the DPID value of the Switch-Port.
33 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080034 @JsonProperty("dpid")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080035 public Dpid dpid() { return dpid; }
36
37 /**
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080038 * Set the DPID value of the Switch-Port.
39 *
40 * @param dpid the DPID to use.
41 */
42 @JsonProperty("dpid")
43 public void setDpid(Dpid dpid) {
44 this.dpid = dpid;
45 }
46
47 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080048 * Get the port value of the Switch-Port.
49 *
50 * @return the port value of the Switch-Port.
51 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080052 @JsonProperty("port")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080053 public Port port() { return port; }
54
55 /**
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080056 * Set the port value of the Switch-Port.
57 *
58 * @param port the port to use.
59 */
60 @JsonProperty("port")
61 public void setPort(Port port) {
62 this.port = port;
63 }
64
65 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080066 * Set the DPID and port values of the Switch-Port.
67 *
68 * @param dpid the DPID to use.
69 * @param port the port to use.
70 */
71 public void setValue(Dpid dpid, Port port) {
72 this.dpid = dpid;
73 this.port = port;
74 }
75
76 /**
77 * Convert the Switch-Port value to a string.
78 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080079 * The string has the following form:
80 * 01:02:03:04:05:06:07:08/1234
81 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080082 * @return the Switch-Port value as a string.
83 */
84 @Override
85 public String toString() {
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080086 return this.dpid.toString() + "/" + this.port;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080087 }
88}