Mass replace CRLF->LF
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / extensibility / 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.extensibility;
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     @Override
32     public int hashCode() {
33         final int prime = 31;
34         int result = 1;
35         result = prime * result + ((clazz == null) ? 0 : clazz.hashCode());
36         result = prime * result + msgType;
37         result = prime * result + msgVersion;
38         return result;
39     }
40
41     @Override
42     public boolean equals(Object obj) {
43         if (this == obj) {
44             return true;
45         }
46         if (obj == null) {
47             return false;
48         }
49         if (!(obj instanceof MessageCodeKey)) {
50             return false;
51         }
52         MessageCodeKey other = (MessageCodeKey) obj;
53         if (clazz == null) {
54             if (other.clazz != null) {
55                 return false;
56             }
57         } else if (!clazz.equals(other.clazz)) {
58             return false;
59         }
60         if (msgType != other.msgType) {
61             return false;
62         }
63         if (msgVersion != other.msgVersion) {
64             return false;
65         }
66         return true;
67     }
68
69     @Override
70     public String toString() {
71         return "msgVersion: " + msgVersion + " objectClass: " + clazz.getName() + " msgType: " + msgType;
72     }
73 }