098f932259dd7ae0d9ee41bf527d6463abe1e381
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / util / TypeToClassKey.java
1 /*\r
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.openflowjava.protocol.impl.util;\r
9 \r
10 /**\r
11  * @author michal.polkorab\r
12  *\r
13  */\r
14 public class TypeToClassKey {\r
15 \r
16     private short version;\r
17     private int type;\r
18 \r
19     /**\r
20      * Constructor\r
21      * @param version wire protocol version\r
22      * @param type message type / code\r
23      */\r
24     public TypeToClassKey(short version, int type) {\r
25         this.version = version;\r
26         this.type = type;\r
27     }\r
28 \r
29     @Override\r
30     public int hashCode() {\r
31         final int prime = 31;\r
32         int result = 1;\r
33         result = prime * result + type;\r
34         return result;\r
35     }\r
36 \r
37     @Override\r
38     public boolean equals(Object obj) {\r
39         if (this == obj) {\r
40             return true;\r
41         }\r
42         if (obj == null) {\r
43             return false;\r
44         }\r
45         if (getClass() != obj.getClass()) {\r
46             return false;\r
47         }\r
48         TypeToClassKey other = (TypeToClassKey) obj;\r
49         if (type != other.type) {\r
50             return false;\r
51         }\r
52         if (version != other.version) {\r
53             return false;\r
54         }\r
55         return true;\r
56     }\r
57 }