1 package org.openflow.codec.protocol;
3 import java.util.HashMap;
7 * Represents struct ofp_hello_elem_type
12 public enum OFPHelloElemType {
13 /* Bitmap of version supported. */
14 VERSIONBITMAP((short) 1, new Instantiable<OFPHelloElemHeader>() {
16 public OFPHelloElemHeader instantiate() {
17 return new OFPHelloElemVersionBitmap();
21 private static Map<Short, OFPHelloElemType> mapping;
25 private Instantiable<OFPHelloElemHeader> instantiable;
31 OFPHelloElemType(short type, Instantiable<OFPHelloElemHeader> instantiable) {
32 this.setTypeValue(type);
33 OFPHelloElemType.addMapping(type, this);
34 this.instantiable = instantiable;
38 * add mapping to store
41 * @param helloElementType
43 private static void addMapping(short type, OFPHelloElemType helloElementType) {
44 if (null == mapping) {
45 mapping = new HashMap<Short, OFPHelloElemType>();
47 mapping.put(type, helloElementType);
51 * get OFHelloElementType correspond to value type
54 * @return OFHelloElementType
56 public static OFPHelloElemType valueOf(short type) {
57 return mapping.get(type);
61 * get HelloElement type value
65 public short getTypeValue() {
70 * set HelloElement type value
74 public void setTypeValue(short type) {
79 * Returns a new instance of the OFPHelloElemHeader represented by this
82 * @return the new object
84 public OFPHelloElemHeader newInstance() {
85 return instantiable.instantiate();