blob: d322f5e940a6e20e6ce2181e1f7c3470ce87c53c [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.FlowEntryIdDeserializer;
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08004import net.floodlightcontroller.util.serializers.FlowEntryIdSerializer;
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 Entry ID.
12 */
Pavlin Radoslavov2013cbb2013-02-26 10:15:18 -080013@JsonDeserialize(using=FlowEntryIdDeserializer.class)
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080014@JsonSerialize(using=FlowEntryIdSerializer.class)
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080015public 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 Radoslavov2013cbb2013-02-26 10:15:18 -080035 * 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 Radoslavov5363c2a2013-02-18 09:55:42 -080044 * 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 Radoslavovad008e02013-02-21 18:42:42 -080060 * Convert the Flow Entry 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 Entry ID value to a hexadecimal string.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080063 */
64 @Override
65 public String toString() {
Pavlin Radoslavovb6f53542013-03-01 16:02:14 -080066 return "0x" + Long.toHexString(this.value);
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080067 }
68}