Merge "OPNFLWPLUG-972: Point to openflowplugin liblldp"
[openflowplugin.git] / openflowjava / 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  *
15  * @author michal.polkorab
16  * @author timotej.kubas
17  */
18 public class MessageTypeCodeKey {
19
20     private final short msgType;
21     private final short msgVersion;
22
23     /**
24      * Constructor.
25      *
26      * @param msgVersion protocol version
27      * @param msgType type code of message
28      */
29     public MessageTypeCodeKey(short msgVersion, short msgType) {
30         this.msgType = msgType;
31         this.msgVersion = msgVersion;
32     }
33
34     /**
35      * Returns the msgType.
36      */
37     public short getMsgType() {
38         return msgType;
39     }
40
41     /**
42      * Returns the msgVersion.
43      */
44     public short getMsgVersion() {
45         return msgVersion;
46     }
47
48     @Override
49     public int hashCode() {
50         final int prime = 31;
51         int result = 1;
52         result = prime * result + msgType;
53         result = prime * result + msgVersion;
54         return result;
55     }
56
57     @Override
58     public boolean equals(Object obj) {
59         if (this == obj) {
60             return true;
61         }
62         if (obj == null) {
63             return false;
64         }
65         if (getClass() != obj.getClass()) {
66             return false;
67         }
68         MessageTypeCodeKey other = (MessageTypeCodeKey) obj;
69         if (msgType != other.msgType) {
70             return false;
71         }
72         if (msgVersion != other.msgVersion) {
73             return false;
74         }
75         return true;
76     }
77 }