blob: 1d0aea74845c72a5c9ce777b196788b94ce14dc3 [file] [log] [blame]
xinwued8d5582013-09-18 17:19:31 -07001package org.projectfloodlight.openflow.types;
2
3import javax.annotation.concurrent.Immutable;
4
5@Immutable
6public class Metadata {
7 static final int LENGTH = 4;
8 private final int rawValue;
9
10 private Metadata(final int rawValue) {
11 this.rawValue = rawValue;
12 }
13
14 public static Metadata of(final int raw) {
15 return new Metadata(raw);
16 }
17
18 public int getInt() {
19 return rawValue;
20 }
21
22 public int getLength() {
23 return LENGTH;
24 }
25
26 @Override
27 public int hashCode() {
28 final int prime = 31;
29 int result = 1;
30 result = prime * result + rawValue;
31 return result;
32 }
33
34 @Override
35 public boolean equals(Object obj) {
36 if (this == obj)
37 return true;
38 if (obj == null)
39 return false;
40 if (getClass() != obj.getClass())
41 return false;
42 Metadata other = (Metadata) obj;
43 if (rawValue != other.rawValue)
44 return false;
45 return true;
46 }
47
48 @Override
49 public String toString() {
50 return Integer.toString(rawValue);
51 }
52}