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 / InstructionSerializerKey.java
diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java
new file mode 100644 (file)
index 0000000..738156a
--- /dev/null
@@ -0,0 +1,66 @@
+/*\r
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.api.keys;\r
+\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ * @param <TYPE> action type\r
+ */\r
+public class InstructionSerializerKey<TYPE extends InstructionBase>\r
+        extends MessageTypeKey<Instruction>{\r
+\r
+    private Class<TYPE> instructionType;\r
+    private Long experimenterId;\r
+\r
+    /**\r
+     * @param msgVersion protocol wire version\r
+     * @param objectType class of serialized object (Instruction.class)\r
+     * @param instructionType type of instruction\r
+     * @param experimenterId experimenter / vendor ID\r
+     */\r
+    public InstructionSerializerKey(short msgVersion, Class<TYPE> instructionType,\r
+            Long experimenterId) {\r
+        super(msgVersion, Instruction.class);\r
+        this.instructionType = instructionType;\r
+        this.experimenterId = experimenterId;\r
+    }\r
+\r
+    @Override\r
+    public boolean equals(Object obj) {\r
+        if (this == obj)\r
+            return true;\r
+        if (!super.equals(obj))\r
+            return false;\r
+        if (getClass() != obj.getClass())\r
+            return false;\r
+        @SuppressWarnings("rawtypes")\r
+        InstructionSerializerKey other = (InstructionSerializerKey) obj;\r
+        if (instructionType == null) {\r
+            if (other.instructionType != null)\r
+                return false;\r
+        } else if (!instructionType.equals(other.instructionType))\r
+            return false;\r
+        if (experimenterId == null) {\r
+            if (other.experimenterId != null)\r
+                return false;\r
+        } else if (!experimenterId.equals(other.experimenterId))\r
+            return false;\r
+        return true;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return super.toString() + " instructionType type: " + instructionType.getName()\r
+                + " vendorID: " + experimenterId;\r
+    }\r
+}
\ No newline at end of file