Allow any hello mesage and extend hello support for v1.4, v1.5
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / MessageCodeKey.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowjava.protocol.api.keys;
9
10 /**
11  * @author michal.polkorab
12  */
13 public class MessageCodeKey {
14
15     private short msgVersion;
16     private int msgType;
17     private Class<?> clazz;
18
19     /**
20      * Constructor
21      * @param version wire protocol version
22      * @param value used as distinguisher (read from binary data / buffer)
23      * @param clazz class of object that is going to be deserialized
24      */
25     public MessageCodeKey(short version, int value, Class<?> clazz) {
26         this.msgVersion = version;
27         this.msgType = value;
28         this.clazz = clazz;
29     }
30
31     public int getMsgType() {
32         return this.msgType;
33     }
34
35     public Class<?> getClazz() {
36         return this.clazz;
37     }
38
39     @Override
40     public int hashCode() {
41         final int prime = 31;
42         int result = 1;
43         result = prime * result + ((clazz == null) ? 0 : clazz.hashCode());
44         result = prime * result + msgType;
45         result = prime * result + msgVersion;
46         return result;
47     }
48
49     @Override
50     public boolean equals(Object obj) {
51         if (this == obj) {
52             return true;
53         }
54         if (obj == null) {
55             return false;
56         }
57         if (!(obj instanceof MessageCodeKey)) {
58             return false;
59         }
60         MessageCodeKey other = (MessageCodeKey) obj;
61         if (clazz == null) {
62             if (other.clazz != null) {
63                 return false;
64             }
65         } else if (!clazz.equals(other.clazz)) {
66             return false;
67         }
68         if (msgType != other.msgType) {
69             return false;
70         }
71         if (msgVersion != other.msgVersion) {
72             return false;
73         }
74         return true;
75     }
76
77     @Override
78     public String toString() {
79         return "msgVersion: " + msgVersion + " objectClass: " + clazz.getName() + " msgType: " + msgType;
80     }
81 }