blob: 713db9a7cdde09af1f93b5d061eb071022112756 [file] [log] [blame]
xinwuc1b011d2013-09-18 15:24:04 -07001package org.projectfloodlight.openflow.types;
2
3import org.jboss.netty.buffer.ChannelBuffer;
xinwu32034432013-09-18 17:17:50 -07004import javax.annotation.concurrent.Immutable;
xinwuc1b011d2013-09-18 15:24:04 -07005
6@Immutable
xinwu32034432013-09-18 17:17:50 -07007public class LagId {
xinwuc1b011d2013-09-18 15:24:04 -07008 static final int LENGTH = 4;
9 private final int rawValue;
10
xinwuc1b011d2013-09-18 15:24:04 -070011 private LagId(final int rawValue) {
12 this.rawValue = rawValue;
13 }
14
15 public static LagId of(final int raw) {
16 return new LagId(raw);
17 }
18
19 public int getInt() {
20 return rawValue;
21 }
22
xinwuc1b011d2013-09-18 15:24:04 -070023 public int getLength() {
24 return LENGTH;
25 }
26
27 @Override
28 public int hashCode() {
29 final int prime = 31;
30 int result = 1;
31 result = prime * result + rawValue;
32 return result;
33 }
34
35 @Override
36 public String toString() {
37 return Integer.toString(rawValue);
38 }
39
40 @Override
41 public boolean equals(final Object obj) {
42 if (this == obj)
43 return true;
44 if (obj == null)
45 return false;
46 if (getClass() != obj.getClass())
47 return false;
48 LagId other = (LagId) obj;
49 if (rawValue != other.rawValue)
50 return false;
51 return true;
52 }
53
xinwuc1b011d2013-09-18 15:24:04 -070054 public void write4Bytes(ChannelBuffer c) {
55 c.writeInt(rawValue);
56 }
57
58 public static LagId read4Bytes(ChannelBuffer c) {
59 return LagId.of(c.readInt());
60 }
61}