Un-uglify AbstractInstructionInfoImpl 67/53467/4
authorStephen Kitt <skitt@redhat.com>
Fri, 17 Mar 2017 09:19:03 +0000 (10:19 +0100)
committerDavid Suarez <david.suarez.fuentes@ericsson.com>
Fri, 17 Mar 2017 15:16:58 +0000 (15:16 +0000)
Abstract classes can override concrete methods with abstract
declarations to force their own sub-classes to re-implement them,
there's no need to use ...2() variants.

Make the equals/hashCode implementations consistent with the rest of
the InstructionInfo implementations.

Change-Id: I948dd27bc57934ad34493244ddb3a26cd30d1393
Signed-off-by: Stephen Kitt <skitt@redhat.com>
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/AbstractInstructionInfoImpl.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionApplyActions.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionClearActions.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionGotoTable.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionWriteActions.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/instructions/InstructionWriteMetadata.java

index 482ecae81a6048a5f001269308f041e5636bb2b9..4ae28fdb825e414e97a7be63a8b91bda01f7b29c 100644 (file)
@@ -11,31 +11,18 @@ import org.opendaylight.genius.mdsalutil.InstructionInfo;
 
 /**
  * Abstract base class for InstructionInfo implementations, to enforce
- * implementation of equals(), hashCode() and toString.
- *
- * @author Michael Vorburger.ch
+ * implementation of equals(), hashCode() and toString().
  */
 /* can remain package local instead of public (unless there are InstructionInfo impls elsewhere?) */
 abstract class AbstractInstructionInfoImpl implements InstructionInfo {
 
     @Override
-    public final boolean equals(Object obj) {
-        return equals2(obj);
-    }
+    public abstract boolean equals(Object other);
 
     @Override
-    public final int hashCode() {
-        return hashCode2();
-    }
+    public abstract int hashCode();
 
     @Override
-    public String toString() {
-        return toString2();
-    }
-
-    protected abstract boolean equals2(Object other);
-
-    protected abstract int hashCode2();
+    public abstract String toString();
 
-    protected abstract String toString2();
 }
index 83941f4fd0588070e0e559def06373311e767dd5..14c4aa9cbf0bd82663831de75749c4c3295706a1 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.genius.mdsalutil.instructions;
 
 import java.util.List;
-import java.util.Objects;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.ActionInfoList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
@@ -16,7 +15,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
-import org.opendaylight.yangtools.util.EvenMoreObjects;
 
 /**
  * Apply actions instruction.
@@ -48,18 +46,26 @@ public class InstructionApplyActions extends AbstractInstructionInfoImpl {
     }
 
     @Override
-    protected boolean equals2(Object obj) {
-        return EvenMoreObjects.equalsHelper(this, obj,
-            (self, other) -> Objects.equals(self.actions, other.actions));
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+        if (other == null || getClass() != other.getClass()) {
+            return false;
+        }
+
+        InstructionApplyActions that = (InstructionApplyActions) other;
+
+        return actions.equals(that.actions);
     }
 
     @Override
-    protected int hashCode2() {
-        return Objects.hash(actions);
+    public int hashCode() {
+        return actions.hashCode();
     }
 
     @Override
-    protected String toString2() {
+    public String toString() {
         return "InstructionApplyActions[" + actions + "]";
     }
 }
index c29e11ba153261c92943a691907c43b9aba87b72..4d3e59e6107ec2f30df0207eb06f5cb1b267af52 100644 (file)
@@ -26,7 +26,7 @@ public class InstructionClearActions extends AbstractInstructionInfoImpl {
     }
 
     @Override
-    public boolean equals2(Object other) {
+    public boolean equals(Object other) {
         if (this == other) {
             return true;
         }
@@ -37,12 +37,12 @@ public class InstructionClearActions extends AbstractInstructionInfoImpl {
     }
 
     @Override
-    public int hashCode2() {
+    public int hashCode() {
         return 17;
     }
 
     @Override
-    protected String toString2() {
+    public String toString() {
         return "InstructionClearActions";
     }
 }
index 12689f6d35f289e9856d294b7d8afc854a99da30..aed89e47918db3b58ba5d065d9b373147ea9fc7d 100644 (file)
@@ -43,7 +43,7 @@ public class InstructionGotoTable extends AbstractInstructionInfoImpl {
     }
 
     @Override
-    public boolean equals2(Object other) {
+    public boolean equals(Object other) {
         if (this == other) {
             return true;
         }
@@ -57,12 +57,12 @@ public class InstructionGotoTable extends AbstractInstructionInfoImpl {
     }
 
     @Override
-    public int hashCode2() {
+    public int hashCode() {
         return tableId;
     }
 
     @Override
-    protected String toString2() {
+    public String toString() {
         return "InstructionGotoTable[" + tableId + "]";
     }
 }
index d8b011324894dab191202164ea0a4742998dbd9b..749e37caaba29ffcf93dc02d039239b58854d551 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.genius.mdsalutil.instructions;
 
 import java.util.List;
-import java.util.Objects;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.ActionInfoList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
@@ -16,7 +15,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
-import org.opendaylight.yangtools.util.EvenMoreObjects;
 
 /**
  * Write actions instruction.
@@ -48,18 +46,26 @@ public class InstructionWriteActions extends AbstractInstructionInfoImpl {
     }
 
     @Override
-    protected boolean equals2(Object obj) {
-        return EvenMoreObjects.equalsHelper(this, obj,
-            (self, other) -> Objects.equals(self.actions, other.actions));
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+        if (other == null || getClass() != other.getClass()) {
+            return false;
+        }
+
+        InstructionWriteActions that = (InstructionWriteActions) other;
+
+        return actions.equals(that.actions);
     }
 
     @Override
-    protected int hashCode2() {
-        return Objects.hash(actions);
+    public int hashCode() {
+        return actions.hashCode();
     }
 
     @Override
-    protected String toString2() {
+    public String toString() {
         return "InstructionWriteActions[" + actions + "]";
     }
 
index fd67c8a0910cac2160f1e655ca328e2a5ea4fb3e..8d934571193418ba871a20cf5e554d88fe3337af 100644 (file)
@@ -51,7 +51,7 @@ public class InstructionWriteMetadata extends AbstractInstructionInfoImpl {
     }
 
     @Override
-    public boolean equals2(Object other) {
+    public boolean equals(Object other) {
         if (this == other) {
             return true;
         }
@@ -68,14 +68,14 @@ public class InstructionWriteMetadata extends AbstractInstructionInfoImpl {
     }
 
     @Override
-    public int hashCode2() {
+    public int hashCode() {
         int result = metadata != null ? metadata.hashCode() : 0;
         result = 31 * result + (mask != null ? mask.hashCode() : 0);
         return result;
     }
 
     @Override
-    protected String toString2() {
+    public String toString() {
         return "InstructionWriteMetadata[metadata=" + metadata + ", mask=" + mask + "]";
     }
 }