Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 1 | package net.floodlightcontroller.util; |
| 2 | |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 3 | import net.floodlightcontroller.util.serializers.FlowEntryIdDeserializer; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 4 | import net.floodlightcontroller.util.serializers.FlowEntryIdSerializer; |
| 5 | |
| 6 | import org.codehaus.jackson.annotate.JsonProperty; |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 7 | import org.codehaus.jackson.map.annotate.JsonDeserialize; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 8 | import org.codehaus.jackson.map.annotate.JsonSerialize; |
| 9 | |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 10 | /** |
| 11 | * The class representing a Flow Entry ID. |
| 12 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 13 | @JsonDeserialize(using=FlowEntryIdDeserializer.class) |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 14 | @JsonSerialize(using=FlowEntryIdSerializer.class) |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 15 | public class FlowEntryId { |
| 16 | private long value; |
| 17 | |
| 18 | /** |
| 19 | * Default constructor. |
| 20 | */ |
| 21 | public FlowEntryId() { |
| 22 | this.value = 0; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Constructor from an integer value. |
| 27 | * |
| 28 | * @param value the value to use. |
| 29 | */ |
| 30 | public FlowEntryId(long value) { |
| 31 | this.value = value; |
| 32 | } |
| 33 | |
| 34 | /** |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 35 | * Constructor from a string. |
| 36 | * |
| 37 | * @param value the value to use. |
| 38 | */ |
| 39 | public FlowEntryId(String value) { |
| 40 | this.value = Long.decode(value); |
| 41 | } |
| 42 | |
| 43 | /** |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 44 | * Get the value of the Flow Entry ID. |
| 45 | * |
| 46 | * @return the value of the Flow Entry ID. |
| 47 | */ |
| 48 | public long value() { return value; } |
| 49 | |
| 50 | /** |
| 51 | * Set the value of the Flow Entry ID. |
| 52 | * |
| 53 | * @param value the value to set. |
| 54 | */ |
| 55 | public void setValue(long value) { |
| 56 | this.value = value; |
| 57 | } |
| 58 | |
| 59 | /** |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 60 | * Convert the Flow Entry ID value to a hexadecimal string. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 61 | * |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 62 | * @return the Flow Entry ID value to a hexadecimal string. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 63 | */ |
| 64 | @Override |
| 65 | public String toString() { |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 66 | return Long.toHexString(this.value); |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 67 | } |
| 68 | } |