int result = 1;\r
result = prime * result + ((clazz == null) ? 0 : clazz.hashCode());\r
result = prime * result + msgType;\r
+ result = prime * result + msgVersion;\r
return result;\r
}\r
\r
return true;\r
if (obj == null)\r
return false;\r
- if (getClass() != obj.getClass())\r
+ if (!(obj instanceof MessageCodeKey))\r
return false;\r
MessageCodeKey other = (MessageCodeKey) obj;\r
if (clazz == null) {\r
public String toString() {\r
return "msgVersion: " + msgVersion + " objectClass: " + clazz.getName() + " msgType: " + msgType;\r
}\r
+\r
}
\ No newline at end of file
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((msgType == null) ? 0 : msgType.getName().hashCode());
+ result = prime * result + ((msgType == null) ? 0 : msgType.hashCode());
+ result = prime * result + msgVersion;
return result;
}
return true;
if (obj == null)
return false;
- if (getClass() != obj.getClass())
+ if (!(obj instanceof MessageTypeKey))
return false;
MessageTypeKey<?> other = (MessageTypeKey<?>) obj;
if (msgType == null) {
if (other.msgType != null)
return false;
- } else if (!other.msgType.getName().equals(msgType.getName()))
+ } else if (!msgType.equals(other.msgType))
return false;
if (msgVersion != other.msgVersion)
return false;
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
+ 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 (getClass() != obj.getClass())\r
+ if (!(obj instanceof ActionDeserializerKey))\r
return false;\r
ActionDeserializerKey other = (ActionDeserializerKey) obj;\r
if (experimenterId == null) {\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 + ((actionType == null) ? 0 : actionType.hashCode());\r
+ result = prime * result + ((experimenterId == null) ? 0 : experimenterId.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 (getClass() != obj.getClass())\r
+ if (!(obj instanceof ActionSerializerKey))\r
return false;\r
- @SuppressWarnings("rawtypes")\r
- ActionSerializerKey other = (ActionSerializerKey) obj;\r
+ ActionSerializerKey<?> other = (ActionSerializerKey<?>) obj;\r
if (actionType == null) {\r
if (other.actionType != null)\r
return false;\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
+ 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 (getClass() != obj.getClass())\r
+ if (!(obj instanceof InstructionDeserializerKey))\r
return false;\r
InstructionDeserializerKey other = (InstructionDeserializerKey) obj;\r
if (experimenterId == null) {\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 (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
+ 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
* @author michal.polkorab\r
*\r
*/\r
-public class MatchEntryDeserializerKey extends MessageCodeKey\r
+public final class MatchEntryDeserializerKey extends MessageCodeKey\r
implements ExperimenterDeserializerKey {\r
\r
private int oxmField;\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 + oxmField;\r
+ return result;\r
+ }\r
+\r
@Override\r
public boolean equals(Object obj) {\r
if (this == obj)\r
* @param <OXM_CLASS> oxm_class (see specification)\r
* @param <OXM_FIELD> oxm_field (see specification)\r
*/\r
-public class MatchEntrySerializerKey<OXM_CLASS extends OxmClassBase, OXM_FIELD extends MatchField>\r
- extends MessageTypeKey<MatchEntries> implements ExperimenterSerializerKey{\r
+public final class MatchEntrySerializerKey<OXM_CLASS extends OxmClassBase, OXM_FIELD extends MatchField>\r
+ extends MessageTypeKey<MatchEntries> implements ExperimenterSerializerKey {\r
\r
private Class<OXM_CLASS> oxmClass;\r
private Class<OXM_FIELD> oxmField;\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 + ((oxmClass == null) ? 0 : oxmClass.hashCode());\r
+ result = prime * result + ((oxmField == null) ? 0 : oxmField.hashCode());\r
+ return result;\r
+ }\r
+\r
@Override\r
public boolean equals(Object obj) {\r
if (this == obj)\r
return false;\r
if (getClass() != obj.getClass())\r
return false;\r
- @SuppressWarnings("rawtypes")\r
- MatchEntrySerializerKey other = (MatchEntrySerializerKey) obj;\r
+ MatchEntrySerializerKey<?, ?> other = (MatchEntrySerializerKey<?, ?>) obj;\r
if (experimenterId == null) {\r
if (other.experimenterId != null)\r
return false;\r
\r
package org.opendaylight.openflowjava.protocol.api.keys.experimenter;\r
\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey;\r
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
\r
/**\r
* @author michal.polkorab\r
*\r
*/\r
-public class ExperimenterActionDeserializerKey extends MessageCodeKey \r
+public final class ExperimenterActionDeserializerKey extends ActionDeserializerKey \r
implements ExperimenterDeserializerKey {\r
\r
- private Long experimenterId;\r
/**\r
* @param version protocol wire version\r
* @param experimenterId experimenter / vendor ID\r
*/\r
public ExperimenterActionDeserializerKey(short version, Long experimenterId) {\r
- super(version, EncodeConstants.EXPERIMENTER_VALUE, Action.class);\r
- this.experimenterId = experimenterId;\r
+ super(version, EncodeConstants.EXPERIMENTER_VALUE, 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
- ExperimenterActionDeserializerKey other = (ExperimenterActionDeserializerKey) obj;\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() + " experimenterID: " + experimenterId;\r
- }\r
}
\ No newline at end of file
\r
package org.opendaylight.openflowjava.protocol.api.keys.experimenter;\r
\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;\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
*/\r
-public class ExperimenterActionSerializerKey extends MessageTypeKey<Action> \r
+public final class ExperimenterActionSerializerKey extends ActionSerializerKey<Experimenter> \r
implements ExperimenterSerializerKey {\r
\r
- private Class<? extends ActionBase> actionType;\r
- private Long experimenterId;\r
-\r
/**\r
* @param msgVersion protocol wire version\r
* @param experimenterId experimenter / vendor ID\r
*/\r
public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId) {\r
- super(msgVersion, Action.class);\r
- this.actionType = Experimenter.class;\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
- ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) 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
+ super(msgVersion, Experimenter.class, experimenterId);\r
}\r
\r
- @Override\r
- public String toString() {\r
- return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId;\r
- }\r
}
\ No newline at end of file
\r
package org.opendaylight.openflowjava.protocol.api.keys.experimenter;\r
\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey;\r
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
\r
/**\r
* @author michal.polkorab\r
*\r
*/\r
-public class ExperimenterInstructionDeserializerKey extends MessageCodeKey\r
+public final class ExperimenterInstructionDeserializerKey extends InstructionDeserializerKey\r
implements ExperimenterDeserializerKey {\r
\r
- private Long experimenterId;\r
/**\r
* @param version protocol wire version\r
* @param experimenterId \r
*/\r
public ExperimenterInstructionDeserializerKey(short version, Long experimenterId) {\r
- super(version, EncodeConstants.EXPERIMENTER_VALUE, Instruction.class);\r
- this.experimenterId = experimenterId;\r
+ super(version, EncodeConstants.EXPERIMENTER_VALUE, 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
- ExperimenterInstructionDeserializerKey other = (ExperimenterInstructionDeserializerKey) obj;\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() + " experimenterID: " + experimenterId;\r
- }\r
}
\ No newline at end of file
\r
package org.opendaylight.openflowjava.protocol.api.keys.experimenter;\r
\r
-import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter;\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
*/\r
-public class ExperimenterInstructionSerializerKey extends MessageTypeKey<Instruction>\r
+public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey<Experimenter>\r
implements ExperimenterSerializerKey {\r
\r
- private Class<? extends InstructionBase> instructionType;\r
- private Long experimenterId;\r
-\r
/**\r
* @param msgVersion protocol wire version\r
* @param experimenterId experimenter / vendor ID\r
*/\r
public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) {\r
- super(msgVersion, Instruction.class);\r
- this.instructionType = Experimenter.class;\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
- ExperimenterInstructionSerializerKey other = (ExperimenterInstructionSerializerKey) 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
+ super(msgVersion, Experimenter.class, experimenterId);\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
--- /dev/null
+package org.opendaylight.openflowjava.protocol.api.keys.extensibility;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;
+
+/**
+ * @author michal.polkorab
+ */
+public class KeysTest {
+
+ /**
+ * Testing equals() and hashcode() methods of extension deserializer's keys
+ */
+ @Test
+ public void testEqualsAndHashcodeOfDeserializerKeys() {
+ ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID,
+ EncodeConstants.EXPERIMENTER_VALUE, 1L);
+ ExperimenterActionDeserializerKey experimenterActionDeserializerKey = new ExperimenterActionDeserializerKey(
+ EncodeConstants.OF13_VERSION_ID, 1L);
+ Assert.assertEquals(actionDeserializerKey, experimenterActionDeserializerKey);
+ Assert.assertEquals(actionDeserializerKey.hashCode(), experimenterActionDeserializerKey.hashCode());
+
+ InstructionDeserializerKey instructionDeserializerKey = new InstructionDeserializerKey(
+ EncodeConstants.OF13_VERSION_ID, EncodeConstants.EXPERIMENTER_VALUE, 1L);
+ ExperimenterInstructionDeserializerKey experimenterInstructionDeserializerKey = new ExperimenterInstructionDeserializerKey(
+ EncodeConstants.OF13_VERSION_ID, 1L);
+ Assert.assertEquals(instructionDeserializerKey, experimenterInstructionDeserializerKey);
+ Assert.assertEquals(instructionDeserializerKey.hashCode(), experimenterInstructionDeserializerKey.hashCode());
+
+
+ }
+
+ /**
+ * Testing equals() and hashcode() methods of extension serializer's keys
+ */
+ @Test
+ public void testEqualsAndHashcodeOfActionDeserializerKeys() {
+ ActionSerializerKey<Experimenter> actionSerializerKey = new ActionSerializerKey<>(
+ EncodeConstants.OF13_VERSION_ID, Experimenter.class, 1L);
+ ExperimenterActionSerializerKey experimenterActionSerializerKey = new ExperimenterActionSerializerKey(
+ EncodeConstants.OF13_VERSION_ID, 1L);
+ Assert.assertEquals(actionSerializerKey, experimenterActionSerializerKey);
+ Assert.assertEquals(actionSerializerKey.hashCode(), experimenterActionSerializerKey.hashCode());
+
+ InstructionSerializerKey<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter> instructionSerializerKey = new InstructionSerializerKey<>(
+ EncodeConstants.OF13_VERSION_ID,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter.class,
+ 1L);
+ ExperimenterInstructionSerializerKey experimenterInstructionSerializerKey = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 1L);
+ Assert.assertEquals(instructionSerializerKey, experimenterInstructionSerializerKey);
+ Assert.assertEquals(instructionSerializerKey.hashCode(), experimenterInstructionSerializerKey.hashCode());
+ }
+
+}