Instruction experimenterId fix
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / InstructionSerializerKey.java
index 899568dc24ae3ac9457bc33f571f92a553eb8f26..89f5cbfead224753c5ea94f54ef9ca77ba8f750f 100644 (file)
@@ -1,74 +1,80 @@
-/*\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 int hashCode() {\r
-        final int prime = 31;\r
-        int result = super.hashCode();\r
-        result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode());\r
-        result = prime * result + ((instructionType == null) ? 0 : instructionType.hashCode());\r
-        return result;\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 (!(obj instanceof InstructionSerializerKey))\r
-            return false;\r
-        InstructionSerializerKey<?> other = (InstructionSerializerKey<?>) obj;\r
-        if (experimenterId == null) {\r
-            if (other.experimenterId != null)\r
-                return false;\r
-        } else if (!experimenterId.equals(other.experimenterId))\r
-            return false;\r
-        if (instructionType == null) {\r
-            if (other.instructionType != null)\r
-                return false;\r
-        } else if (!instructionType.equals(other.instructionType))\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
+/*
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.api.keys;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.InstructionChoice;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+
+/**
+ * @author michal.polkorab
+ * @param <T> instruction type
+ */
+public class InstructionSerializerKey<T extends InstructionChoice>
+        extends MessageTypeKey<Instruction> implements ExperimenterSerializerKey {
+
+    private Class<T> instructionType;
+    private Long experimenterId;
+
+    /**
+     * @param msgVersion protocol wire version
+     * @param objectType class of serialized object (Instruction.class)
+     * @param instructionType type of instruction
+     * @param experimenterId experimenter / vendor ID
+     */
+    public InstructionSerializerKey(short msgVersion, Class<T> instructionType,
+            Long experimenterId) {
+        super(msgVersion, Instruction.class);
+        this.instructionType = instructionType;
+        this.experimenterId = experimenterId;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode());
+        result = prime * result + ((instructionType == null) ? 0 : instructionType.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (!(obj instanceof InstructionSerializerKey)) {
+            return false;
+        }
+        InstructionSerializerKey<?> other = (InstructionSerializerKey<?>) obj;
+        if (experimenterId == null) {
+            if (other.experimenterId != null) {
+                return false;
+            }
+        } else if (!experimenterId.equals(other.experimenterId)) {
+            return false;
+        }
+        if (instructionType == null) {
+            if (other.instructionType != null) {
+                return false;
+            }
+        } else if (!instructionType.equals(other.instructionType)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return super.toString() + " instructionType type: " + instructionType.getName()
+                + " vendorID: " + experimenterId;
+    }
 }
\ No newline at end of file