Bug 2245 - Fixed 'If Stmts Must Use Braces'
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / MessageTypeCodeKey.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
9 package org.opendaylight.openflowjava.protocol.impl.deserialization;
10
11
12 /**
13  * Class used as a key in {@link DeserializerRegistryImpl}
14  * @author michal.polkorab
15  * @author timotej.kubas
16  */
17 public class MessageTypeCodeKey {
18
19     private final short msgType;
20     private final short msgVersion;
21
22     /**
23      * @param msgVersion protocol version
24      * @param msgType type code of message
25      */
26     public MessageTypeCodeKey(short msgVersion, short msgType) {
27         this.msgType = msgType;
28         this.msgVersion = msgVersion;
29     }
30
31     /**
32      * @return the msgType
33      */
34     public short getMsgType() {
35         return msgType;
36     }
37
38     /**
39      * @return the msgVersion
40      */
41     public short getMsgVersion() {
42         return msgVersion;
43     }
44
45     @Override
46     public int hashCode() {
47         final int prime = 31;
48         int result = 1;
49         result = prime * result + msgType;
50         result = prime * result + msgVersion;
51         return result;
52     }
53
54     @Override
55     public boolean equals(Object obj) {
56         if (this == obj) {
57             return true;
58         }
59         if (obj == null) {
60             return false;
61         }
62         if (getClass() != obj.getClass()) {
63             return false;
64         }
65         MessageTypeCodeKey other = (MessageTypeCodeKey) obj;
66         if (msgType != other.msgType) {
67             return false;
68         }
69         if (msgVersion != other.msgVersion) {
70             return false;
71         }
72         return true;
73     }
74 }