Mass replace CRLF->LF
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / extensibility / EnhancedMessageTypeKey.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 /**
12  * More specific key for {@link SerializerRegistry}
13  * @author michal.polkorab
14  * @param <E> main type
15  * @param <F> specific type
16  */
17 public class EnhancedMessageTypeKey<E, F> extends MessageTypeKey<E> {
18
19     private final Class<F> msgType2;
20
21     /**
22      * @param msgVersion
23      * @param msgType
24      * @param msgType2
25      */
26     public EnhancedMessageTypeKey(short msgVersion, Class<E> msgType, Class<F> msgType2) {
27         super(msgVersion, msgType);
28         this.msgType2 = msgType2;
29     }
30
31     @Override
32     public int hashCode() {
33         final int prime = 31;
34         int result = super.hashCode();
35         result = prime * result + ((msgType2 == null) ? 0 : msgType2.hashCode());
36         return result;
37     }
38     
39     @Override
40     public boolean equals(Object obj) {
41         if (this == obj) {
42             return true;
43         }
44         if (!super.equals(obj)) {
45             return false;
46         }
47         if (getClass() != obj.getClass()) {
48             return false;
49         }
50         @SuppressWarnings("rawtypes")
51         EnhancedMessageTypeKey other = (EnhancedMessageTypeKey) obj;
52         if (msgType2 == null) {
53             if (other.msgType2 != null) {
54                 return false;
55             }
56         } else if (!msgType2.getName().equals(other.msgType2.getName())) {
57             return false;
58         }
59         return true;
60     }
61
62     @Override
63     public String toString() {
64         return super.toString() + " msgType2: " + msgType2.getName();
65     }
66 }