Extensibility support (deserialization part)
[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         if (obj == null)
59             return false;
60         if (getClass() != obj.getClass())
61             return false;
62         MessageTypeCodeKey other = (MessageTypeCodeKey) obj;
63         if (msgType != other.msgType)
64             return false;
65         if (msgVersion != other.msgVersion)
66             return false;
67         return true;
68     }
69     
70 }