Extensibility support (serialization part)
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / EnhancedMessageTypeKey.java
1 /*\r
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.openflowjava.protocol.impl.deserialization;\r
9 \r
10 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;\r
11 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;\r
12 \r
13 /**\r
14  * More specific key for {@link SerializerRegistry}\r
15  * @author michal.polkorab\r
16  * @param <E> main type\r
17  * @param <F> specific type\r
18  */\r
19 public class EnhancedMessageTypeKey<E, F> extends MessageTypeKey<E> {\r
20 \r
21     private final Class<F> msgType2;\r
22 \r
23     /**\r
24      * @param msgVersion\r
25      * @param msgType\r
26      * @param msgType2\r
27      */\r
28     public EnhancedMessageTypeKey(short msgVersion, Class<E> msgType, Class<F> msgType2) {\r
29         super(msgVersion, msgType);\r
30         this.msgType2 = msgType2;\r
31     }\r
32 \r
33     /**\r
34      * @return more specific type\r
35      */\r
36     public Class<F> getMsgType2() {\r
37         return msgType2;\r
38     }\r
39 \r
40     @Override\r
41     public boolean equals(Object obj) {\r
42         if (this == obj)\r
43             return true;\r
44         if (!super.equals(obj))\r
45             return false;\r
46         if (getClass() != obj.getClass())\r
47             return false;\r
48         @SuppressWarnings("rawtypes")\r
49         EnhancedMessageTypeKey other = (EnhancedMessageTypeKey) obj;\r
50         if (msgType2 == null) {\r
51             if (other.msgType2 != null)\r
52                 return false;\r
53         } else if (!msgType2.equals(other.msgType2))\r
54             return false;\r
55         return true;\r
56     }\r
57 \r
58     @Override\r
59     public String toString() {\r
60         return super.toString() + " msgType2: " + msgType2.getName();\r
61     }\r
62 }\r