blob: 77879539ce699e806a0fba37c349f6285e091043 [file] [log] [blame]
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08001package net.floodlightcontroller.util;
2
Pavlin Radoslavovad008e02013-02-21 18:42:42 -08003import org.openflow.util.HexString;
4import net.floodlightcontroller.util.serializers.DpidSerializer;
5
6import org.codehaus.jackson.annotate.JsonProperty;
7import org.codehaus.jackson.map.annotate.JsonSerialize;
8
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -08009/**
10 * The class representing a network switch DPID.
11 */
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080012@JsonSerialize(using=DpidSerializer.class)
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080013public class Dpid {
14 static public long UNKNOWN = 0;
15
16 private long value;
17
18 /**
19 * Default constructor.
20 */
21 public Dpid() {
22 this.value = Dpid.UNKNOWN;
23 }
24
25 /**
26 * Constructor from a long value.
27 *
28 * @param value the value to use.
29 */
30 public Dpid(long value) {
31 this.value = value;
32 }
33
34 /**
35 * Get the value of the DPID.
36 *
37 * @return the value of the DPID.
38 */
39 public long value() { return value; }
40
41 /**
42 * Set the value of the DPID.
43 *
44 * @param value the value to set.
45 */
46 public void setValue(long value) {
47 this.value = value;
48 }
49
50 /**
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080051 * Convert the DPID value to a ':' separated hexadecimal string.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080052 *
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080053 * @return the DPID value as a ':' separated hexadecimal string.
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080054 */
55 @Override
56 public String toString() {
Pavlin Radoslavovad008e02013-02-21 18:42:42 -080057 return HexString.toHexString(this.value);
Pavlin Radoslavov5363c2a2013-02-18 09:55:42 -080058 }
59}