blob: 462cdfbb17733abb58d020755dcb184c995d25c7 [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 -08005import net.floodlightcontroller.util.serializers.SwitchPortSerializer;
6
7import org.codehaus.jackson.annotate.JsonProperty;
8import org.codehaus.jackson.map.annotate.JsonSerialize;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08009
10/**
11 * The class representing a Switch-Port.
12 */
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080013@JsonSerialize(using=SwitchPortSerializer.class)
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080014public class SwitchPort {
15 private Dpid dpid; // The DPID of the switch
16 private Port port; // The port of the switch
17
18 /**
19 * Default constructor.
20 */
21 public SwitchPort() {
22 }
23
24 /**
25 * Constructor for a given DPID and a port.
26 *
27 * @param dpid the DPID to use.
28 * @param port the port to use.
29 */
30 public SwitchPort(Dpid dpid, Port port) {
31 this.dpid = dpid;
32 this.port = port;
33 }
34
35 /**
36 * Get the DPID value of the Switch-Port.
37 *
38 * @return the DPID value of the Switch-Port.
39 */
40 public Dpid dpid() { return dpid; }
41
42 /**
43 * Get the port value of the Switch-Port.
44 *
45 * @return the port value of the Switch-Port.
46 */
47 public Port port() { return port; }
48
49 /**
50 * Set the DPID and port values of the Switch-Port.
51 *
52 * @param dpid the DPID to use.
53 * @param port the port to use.
54 */
55 public void setValue(Dpid dpid, Port port) {
56 this.dpid = dpid;
57 this.port = port;
58 }
59
60 /**
61 * Convert the Switch-Port value to a string.
62 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080063 * The string has the following form:
64 * 01:02:03:04:05:06:07:08/1234
65 *
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080066 * @return the Switch-Port value as a string.
67 */
68 @Override
69 public String toString() {
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080070 return this.dpid.toString() + "/" + this.port;
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080071 }
72}