blob: 19bbf8f330155a9d136b18da859db5782c952c7d [file] [log] [blame]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08001package net.floodlightcontroller.util;
2
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08003import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08004
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08005/**
6 * The class representing a network port of a switch.
7 */
8public class Port {
9 private short value;
10
11 /**
12 * Default constructor.
13 */
14 public Port() {
15 this.value = 0;
16 }
17
18 /**
Pavlin Radoslavovf83aa442013-02-26 14:09:01 -080019 * Constructor from another entry.
20 *
21 * @param other the other entry to use.
22 */
23 public Port(Port other) {
24 this.value = other.value();
25 }
26
27 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080028 * Constructor from a long value.
29 *
30 * @param value the value to use.
31 */
32 public Port(short value) {
33 this.value = value;
34 }
35
36 /**
37 * Get the value of the port.
38 *
39 * @return the value of the port.
40 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080041 @JsonProperty("value")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080042 public short value() { return value; }
43
44 /**
45 * Set the value of the port.
46 *
47 * @param value the value to set.
48 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080049 @JsonProperty("value")
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080050 public void setValue(short value) {
51 this.value = value;
52 }
53
54 /**
55 * Convert the port value to a string.
56 *
57 * @return the port value as a string.
58 */
59 @Override
60 public String toString() {
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080061 return Short.toString(this.value);
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080062 }
63}