Making all these fields final and explicitly initialize to null 24/41524/2
authorMichael Vorburger <vorburger@redhat.com>
Fri, 8 Jul 2016 02:07:50 +0000 (04:07 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Fri, 8 Jul 2016 17:14:26 +0000 (19:14 +0200)
This makes the intention of the code in these classes much clearer to
read (the idea of the API as-is seems to be that always only either of
the 3 is set).

Removal of setInstructionValues in InstructionInfo is only consistent
then.

Change-Id: I4a0c540df0a4526f6ff326b5386260e291085275
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/InstructionInfo.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/MatchInfo.java
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/genius/mdsalutil/NxMatchInfo.java

index a9fea8b9fc6dd01ee70b076590767ddf926a3be8..6e085a2a8f75338587c4a68706e152d378d6c9ce 100644 (file)
@@ -20,28 +20,36 @@ public class InstructionInfo implements Serializable {
     private static final long serialVersionUID = 1L;
 
     private final InstructionType m_instructionType;
-
-    private long[] m_alInstructionValues;
-    private BigInteger[] m_alBigInstructionValues;
-    private List<ActionInfo> m_actionInfos;
+    private final long[] m_alInstructionValues;
+    private final BigInteger[] m_alBigInstructionValues;
+    private final List<ActionInfo> m_actionInfos;
 
     // This constructor should be used incase of clearAction
     public InstructionInfo(InstructionType instructionType) {
         m_instructionType = instructionType;
+        m_alInstructionValues = null;
+        m_alBigInstructionValues = null;
+        m_actionInfos = null;
     }
 
     public InstructionInfo(InstructionType instructionType, long[] instructionValues) {
         m_instructionType = instructionType;
         m_alInstructionValues = instructionValues;
+        m_alBigInstructionValues = null;
+        m_actionInfos = null;
     }
 
     public InstructionInfo(InstructionType instructionType, BigInteger[] instructionValues) {
         m_instructionType = instructionType;
+        m_alInstructionValues = null;
         m_alBigInstructionValues = instructionValues;
+        m_actionInfos = null;
     }
 
     public InstructionInfo(InstructionType instructionType, List<ActionInfo> actionInfos) {
         m_instructionType = instructionType;
+        m_alInstructionValues = null;
+        m_alBigInstructionValues = null;
         m_actionInfos = actionInfos;
     }
 
@@ -65,10 +73,6 @@ public class InstructionInfo implements Serializable {
         return m_actionInfos;
     }
 
-    public void setInstructionValues(long[] m_alInstructionValues) {
-        this.m_alInstructionValues = m_alInstructionValues;
-    }
-
     @Override
     public String toString() {
         return MoreObjects.toStringHelper(this).omitNullValues().add("instructionType", m_instructionType)
@@ -76,5 +80,4 @@ public class InstructionInfo implements Serializable {
                 .add("bigInstructionValues", Arrays.deepToString(m_alBigInstructionValues))
                 .add("actionInfos", m_actionInfos).toString();
     }
-
 }
index 1769075bf2277edfe40821b44f0922ce7cab9038..8b1f51de522bc9976ac9a78a982884c932387b55 100644 (file)
@@ -19,22 +19,28 @@ public class MatchInfo implements Serializable, MatchInfoBase {
     private static final long serialVersionUID = 1L;
 
     private final MatchFieldType m_matchField;
-    private long[] m_alMatchValues;
-    private BigInteger[] m_aBigIntValues;
-    private String[] m_asMatchValues;
+    private final long[] m_alMatchValues;
+    private final BigInteger[] m_aBigIntValues;
+    private final String[] m_asMatchValues;
 
     public MatchInfo(MatchFieldType matchField, long[] alMatchValues) {
         m_matchField = matchField;
         m_alMatchValues = alMatchValues;
+        m_aBigIntValues = null;
+        m_asMatchValues = null;
     }
 
     public MatchInfo(MatchFieldType matchField, BigInteger[] alBigMatchValues) {
         m_matchField = matchField;
+        m_alMatchValues = null;
         m_aBigIntValues = alBigMatchValues;
+        m_asMatchValues = null;
     }
 
     public MatchInfo(MatchFieldType matchField, String[] alStringMatchValues) {
         m_matchField = matchField;
+        m_alMatchValues = null;
+        m_aBigIntValues = null;
         m_asMatchValues = alStringMatchValues;
     }
 
index 62298da709dd16e52b3269cdab59dbd84d53cee3..9700b92d5b9a9c190405b6273b2299705383ef6f 100644 (file)
@@ -23,23 +23,28 @@ public class NxMatchInfo implements Serializable, MatchInfoBase {
     private static final long serialVersionUID = 1L;
 
     private final NxMatchFieldType m_matchField;
-
-    private long[] m_alMatchValues;
-    private BigInteger[] m_aBigIntValues;
-    private String[] m_asMatchValues;
+    private final long[] m_alMatchValues;
+    private final BigInteger[] m_aBigIntValues;
+    private final String[] m_asMatchValues;
 
     public NxMatchInfo(NxMatchFieldType matchField, long[] alMatchValues) {
         m_matchField = matchField;
         m_alMatchValues = alMatchValues;
+        m_aBigIntValues = null;
+        m_asMatchValues = null;
     }
 
     public NxMatchInfo(NxMatchFieldType matchField, BigInteger[] alBigMatchValues) {
         m_matchField = matchField;
+        m_alMatchValues = null;
         m_aBigIntValues = alBigMatchValues;
+        m_asMatchValues = null;
     }
 
     public NxMatchInfo(NxMatchFieldType matchField, String[] alStringMatchValues) {
         m_matchField = matchField;
+        m_alMatchValues = null;
+        m_aBigIntValues = null;
         m_asMatchValues = alStringMatchValues;
     }