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 | /** |
| 19 | * Constructor from a long value. |
| 20 | * |
| 21 | * @param value the value to use. |
| 22 | */ |
| 23 | public Port(short value) { |
| 24 | this.value = value; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Get the value of the port. |
| 29 | * |
| 30 | * @return the value of the port. |
| 31 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame^] | 32 | @JsonProperty("value") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 33 | public short value() { return value; } |
| 34 | |
| 35 | /** |
| 36 | * Set the value of the port. |
| 37 | * |
| 38 | * @param value the value to set. |
| 39 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame^] | 40 | @JsonProperty("value") |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 41 | public void setValue(short value) { |
| 42 | this.value = value; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Convert the port value to a string. |
| 47 | * |
| 48 | * @return the port value as a string. |
| 49 | */ |
| 50 | @Override |
| 51 | public String toString() { |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 52 | return Short.toString(this.value); |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 53 | } |
| 54 | } |