blob: 297c0c4b5c9cecbbe983bc63db9552af55f47f1f [file] [log] [blame]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08001package net.floodlightcontroller.util;
2
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -08003import net.floodlightcontroller.util.serializers.FlowIdDeserializer;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08004import net.floodlightcontroller.util.serializers.FlowIdSerializer;
5
6import org.codehaus.jackson.annotate.JsonProperty;
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -08007import org.codehaus.jackson.map.annotate.JsonDeserialize;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08008import org.codehaus.jackson.map.annotate.JsonSerialize;
9
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080010/**
11 * The class representing a Flow ID.
12 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080013@JsonDeserialize(using=FlowIdDeserializer.class)
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080014@JsonSerialize(using=FlowIdSerializer.class)
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080015public class FlowId {
16 private long value;
17
18 /**
19 * Default constructor.
20 */
21 public FlowId() {
22 this.value = 0;
23 }
24
25 /**
26 * Constructor from an integer value.
27 *
28 * @param value the value to use.
29 */
30 public FlowId(long value) {
31 this.value = value;
32 }
33
34 /**
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080035 * Constructor from a string.
36 *
37 * @param value the value to use.
38 */
39 public FlowId(String value) {
40 this.value = Long.decode(value);
41 }
42
43 /**
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080044 * Get the value of the Flow ID.
45 *
46 * @return the value of the Flow ID.
47 */
48 public long value() { return value; }
49
50 /**
51 * Set the value of the Flow ID.
52 *
53 * @param value the value to set.
54 */
55 public void setValue(long value) {
56 this.value = value;
57 }
58
59 /**
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080060 * Convert the Flow ID value to a hexadecimal string.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080061 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080062 * @return the Flow ID value to a hexadecimal string.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080063 */
64 @Override
65 public String toString() {
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080066 return "0x" + Long.toHexString(this.value);
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080067 }
68}