Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.util; |
| 2 | |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 3 | import org.codehaus.jackson.annotate.JsonProperty; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 4 | |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 5 | /** |
| 6 | * The class representing a network port of a switch. |
| 7 | */ |
| 8 | public class Port { |
| 9 | private short value; |
| 10 | |
| 11 | /** |
| 12 | * Default constructor. |
| 13 | */ |
| 14 | public Port() { |
| 15 | this.value = 0; |
| 16 | } |
| 17 | |
| 18 | /** |
Pavlin Radoslavov | f83aa44 | 2013-02-26 14:09:01 -0800 | [diff] [blame] | 19 | * 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 Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 28 | * 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 Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 41 | @JsonProperty("value") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 42 | public short value() { return value; } |
| 43 | |
| 44 | /** |
| 45 | * Set the value of the port. |
| 46 | * |
| 47 | * @param value the value to set. |
| 48 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 49 | @JsonProperty("value") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 50 | 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 Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 61 | return Short.toString(this.value); |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 62 | } |
| 63 | } |