Instruction experimenterId fix
[openflowjava.git] / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / keys / ActionSerializerKey.java
index 623bdea4b9bd238c99cf930b6ac07414f9405481..7d096f84e533c356d8894d03a11965a624980165 100644 (file)
@@ -1,63 +1,78 @@
-/*\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.action.rev130731.actions.grouping.Action;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase;\r
-\r
-/**\r
- * @author michal.polkorab\r
- * @param <TYPE> action type\r
- */\r
-public class ActionSerializerKey<TYPE extends ActionBase> extends MessageTypeKey<Action> {\r
-\r
-    private Class<TYPE> actionType;\r
-    private Long experimenterId;\r
-\r
-    /**\r
-     * @param msgVersion protocol wire version\r
-     * @param actionType type of action\r
-     * @param experimenterId experimenter / vendor ID\r
-     */\r
-    public ActionSerializerKey(short msgVersion, Class<TYPE> actionType,\r
-            Long experimenterId) {\r
-        super(msgVersion, Action.class);\r
-        this.actionType = actionType;\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
-        ActionSerializerKey other = (ActionSerializerKey) obj;\r
-        if (actionType == null) {\r
-            if (other.actionType != null)\r
-                return false;\r
-        } else if (!actionType.equals(other.actionType))\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() + " action type: " + actionType.getName() + " experimenterID: " + 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.action.rev150203.action.grouping.ActionChoice;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+
+/**
+ * @author michal.polkorab
+ * @param <T> action type
+ */
+public class ActionSerializerKey<T extends ActionChoice> extends MessageTypeKey<Action>
+        implements ExperimenterSerializerKey {
+
+    private Class<T> actionType;
+    private Long experimenterId;
+
+    /**
+     * @param msgVersion protocol wire version
+     * @param actionType type of action
+     * @param experimenterId experimenter / vendor ID
+     */
+    public ActionSerializerKey(short msgVersion, Class<T> actionType,
+            Long experimenterId) {
+        super(msgVersion, Action.class);
+        this.actionType = actionType;
+        this.experimenterId = experimenterId;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((actionType == null) ? 0 : actionType.hashCode());
+        result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        ActionSerializerKey<?> other = (ActionSerializerKey<?>) obj;
+        if (actionType == null) {
+            if (other.actionType != null) {
+                return false;
+            }
+        } else if (!actionType.equals(other.actionType)) {
+            return false;
+        }
+        if (experimenterId == null) {
+            if (other.experimenterId != null) {
+                return false;
+            }
+        } else if (!experimenterId.equals(other.experimenterId)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId;
+    }
 }
\ No newline at end of file