Created special extension keys for more easier (de)serializer (un)registration
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / experimenter / ExperimenterInstructionSerializerKey.java
1 /*\r
2  * Copyright (c) 2014 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 \r
9 package org.opendaylight.openflowjava.protocol.api.keys.experimenter;\r
10 \r
11 import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;\r
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;\r
15 \r
16 /**\r
17  * @author michal.polkorab\r
18  */\r
19 public class ExperimenterInstructionSerializerKey extends MessageTypeKey<Instruction>\r
20         implements ExperimenterSerializerKey {\r
21 \r
22     private Class<? extends InstructionBase> instructionType;\r
23     private Long experimenterId;\r
24 \r
25     /**\r
26      * @param msgVersion protocol wire version\r
27      * @param experimenterId experimenter / vendor ID\r
28      */\r
29     public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) {\r
30         super(msgVersion, Instruction.class);\r
31         this.instructionType = Experimenter.class;\r
32         this.experimenterId = experimenterId;\r
33     }\r
34 \r
35     @Override\r
36     public boolean equals(Object obj) {\r
37         if (this == obj)\r
38             return true;\r
39         if (!super.equals(obj))\r
40             return false;\r
41         if (getClass() != obj.getClass())\r
42             return false;\r
43         ExperimenterInstructionSerializerKey other = (ExperimenterInstructionSerializerKey) obj;\r
44         if (instructionType == null) {\r
45             if (other.instructionType != null)\r
46                 return false;\r
47         } else if (!instructionType.equals(other.instructionType))\r
48             return false;\r
49         if (experimenterId == null) {\r
50             if (other.experimenterId != null)\r
51                 return false;\r
52         } else if (!experimenterId.equals(other.experimenterId))\r
53             return false;\r
54         return true;\r
55     }\r
56 \r
57     @Override\r
58     public String toString() {\r
59         return super.toString() + " instructionType type: " + instructionType.getName()\r
60                 + " vendorID: " + experimenterId;\r
61     }\r
62 }