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.FlowIdSerializer; |
| 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 Flow ID. |
| 10 | */ |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame^] | 11 | @JsonSerialize(using=FlowIdSerializer.class) |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 12 | public class FlowId { |
| 13 | private long value; |
| 14 | |
| 15 | /** |
| 16 | * Default constructor. |
| 17 | */ |
| 18 | public FlowId() { |
| 19 | this.value = 0; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Constructor from an integer value. |
| 24 | * |
| 25 | * @param value the value to use. |
| 26 | */ |
| 27 | public FlowId(long value) { |
| 28 | this.value = value; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Get the value of the Flow ID. |
| 33 | * |
| 34 | * @return the value of the Flow ID. |
| 35 | */ |
| 36 | public long value() { return value; } |
| 37 | |
| 38 | /** |
| 39 | * Set the value of the Flow ID. |
| 40 | * |
| 41 | * @param value the value to set. |
| 42 | */ |
| 43 | public void setValue(long value) { |
| 44 | this.value = value; |
| 45 | } |
| 46 | |
| 47 | /** |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame^] | 48 | * Convert the Flow ID value to a hexadecimal string. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 49 | * |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame^] | 50 | * @return the Flow ID value to a hexadecimal string. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 51 | */ |
| 52 | @Override |
| 53 | public String toString() { |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame^] | 54 | return "0x" + Long.toHexString(this.value); |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 55 | } |
| 56 | } |