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 net.floodlightcontroller.util.serializers.PortSerializer; |
| 4 | |
| 5 | import org.codehaus.jackson.annotate.JsonProperty; |
| 6 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
| 7 | |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 8 | /** |
| 9 | * The class representing a network port of a switch. |
| 10 | */ |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame^] | 11 | @JsonSerialize(using=PortSerializer.class) |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 12 | public class Port { |
| 13 | private short value; |
| 14 | |
| 15 | /** |
| 16 | * Default constructor. |
| 17 | */ |
| 18 | public Port() { |
| 19 | this.value = 0; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Constructor from a long value. |
| 24 | * |
| 25 | * @param value the value to use. |
| 26 | */ |
| 27 | public Port(short value) { |
| 28 | this.value = value; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Get the value of the port. |
| 33 | * |
| 34 | * @return the value of the port. |
| 35 | */ |
| 36 | public short value() { return value; } |
| 37 | |
| 38 | /** |
| 39 | * Set the value of the port. |
| 40 | * |
| 41 | * @param value the value to set. |
| 42 | */ |
| 43 | public void setValue(short value) { |
| 44 | this.value = value; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Convert the port value to a string. |
| 49 | * |
| 50 | * @return the port value as a string. |
| 51 | */ |
| 52 | @Override |
| 53 | public String toString() { |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame^] | 54 | return Short.toString(this.value); |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 55 | } |
| 56 | } |