Eliminate AbstractEmptyActionDeserializer subclasses 88/92388/13
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 2 Sep 2020 16:57:27 +0000 (18:57 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 18 Sep 2020 05:58:41 +0000 (07:58 +0200)
Method dispatch works on particular class implementation and
individual per-type subclasses are not bringing anything to the
table.

Change AbstractEmptyActionDeserializer to a final
EmptyActionDeserializer and use its instances to perform duties
previously held by its subclasses.

JIRA: OPNFLWPLUG-1102
Change-Id: I3e1e03a498a15808cf2538fcca651c6c258e07f5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/EmptyActionDeserializer.java [moved from openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEmptyActionDeserializer.java with 80% similarity]
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java [deleted file]
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java [deleted file]
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java [deleted file]
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java [deleted file]
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java [deleted file]
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java [deleted file]
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java [deleted file]

index 786b3b093df7ea36f492219def2b099e314a4837..a9bd3334bb740c8316ca407b33f60a2b7bde8725 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization;
 
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.deserialization.action.EmptyActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10EnqueueActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10OutputActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlDstActionDeserializer;
@@ -20,16 +21,9 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10Se
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetTpSrcActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanPcpActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanVidActionDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10StripVlanActionDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlInActionDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlOutActionDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecMplsTtlActionDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecNwTtlActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13GroupActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13OutputActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopMplsActionDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopPbbActionDeserializer;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopVlanActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushMplsActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushPbbActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushVlanActionDeserializer;
@@ -39,6 +33,13 @@ import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13Se
 import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetQueueActionDeserializer;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionDeserializerRegistryHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder;
 
 /**
  * Helper for registering action deserializer initializers.
@@ -62,7 +63,8 @@ public final class ActionDeserializerInitializer {
         helper.registerDeserializer(ActionConstants.OUTPUT_CODE, new OF10OutputActionDeserializer());
         helper.registerDeserializer(ActionConstants.SET_VLAN_VID_CODE, new OF10SetVlanVidActionDeserializer());
         helper.registerDeserializer(ActionConstants.SET_VLAN_PCP_CODE, new OF10SetVlanPcpActionDeserializer());
-        helper.registerDeserializer(ActionConstants.STRIP_VLAN_CODE, new OF10StripVlanActionDeserializer());
+        helper.registerDeserializer(ActionConstants.STRIP_VLAN_CODE,
+            new EmptyActionDeserializer<>(new StripVlanCaseBuilder().build()));
         helper.registerDeserializer(ActionConstants.SET_DL_SRC_CODE, new OF10SetDlSrcActionDeserializer());
         helper.registerDeserializer(ActionConstants.SET_DL_DST_CODE, new OF10SetDlDstActionDeserializer());
         helper.registerDeserializer(ActionConstants.SET_NW_SRC_CODE, new OF10SetNwSrcActionDeserializer());
@@ -74,20 +76,26 @@ public final class ActionDeserializerInitializer {
         // register OF v1.3 action deserializers
         helper = new ActionDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry);
         helper.registerDeserializer(ActionConstants.OUTPUT_CODE, new OF13OutputActionDeserializer());
-        helper.registerDeserializer(ActionConstants.COPY_TTL_OUT_CODE, new OF13CopyTtlOutActionDeserializer());
-        helper.registerDeserializer(ActionConstants.COPY_TTL_IN_CODE, new OF13CopyTtlInActionDeserializer());
+        helper.registerDeserializer(ActionConstants.COPY_TTL_OUT_CODE,
+            new EmptyActionDeserializer<>(new CopyTtlOutCaseBuilder().build()));
+        helper.registerDeserializer(ActionConstants.COPY_TTL_IN_CODE,
+            new EmptyActionDeserializer<>(new CopyTtlInCaseBuilder().build()));
         helper.registerDeserializer(ActionConstants.SET_MPLS_TTL_CODE, new OF13SetMplsTtlActionDeserializer());
-        helper.registerDeserializer(ActionConstants.DEC_MPLS_TTL_CODE, new OF13DecMplsTtlActionDeserializer());
+        helper.registerDeserializer(ActionConstants.DEC_MPLS_TTL_CODE,
+            new EmptyActionDeserializer<>(new DecMplsTtlCaseBuilder().build()));
         helper.registerDeserializer(ActionConstants.PUSH_VLAN_CODE, new OF13PushVlanActionDeserializer());
-        helper.registerDeserializer(ActionConstants.POP_VLAN_CODE, new OF13PopVlanActionDeserializer());
+        helper.registerDeserializer(ActionConstants.POP_VLAN_CODE,
+            new EmptyActionDeserializer<>(new PopVlanCaseBuilder().build()));
         helper.registerDeserializer(ActionConstants.PUSH_MPLS_CODE, new OF13PushMplsActionDeserializer());
         helper.registerDeserializer(ActionConstants.POP_MPLS_CODE, new OF13PopMplsActionDeserializer());
         helper.registerDeserializer(ActionConstants.SET_QUEUE_CODE, new OF13SetQueueActionDeserializer());
         helper.registerDeserializer(ActionConstants.GROUP_CODE, new OF13GroupActionDeserializer());
         helper.registerDeserializer(ActionConstants.SET_NW_TTL_CODE, new OF13SetNwTtlActionDeserializer());
-        helper.registerDeserializer(ActionConstants.DEC_NW_TTL_CODE, new OF13DecNwTtlActionDeserializer());
+        helper.registerDeserializer(ActionConstants.DEC_NW_TTL_CODE,
+            new EmptyActionDeserializer<>(new DecNwTtlCaseBuilder().build()));
         helper.registerDeserializer(ActionConstants.SET_FIELD_CODE, new OF13SetFieldActionDeserializer());
         helper.registerDeserializer(ActionConstants.PUSH_PBB_CODE, new OF13PushPbbActionDeserializer());
-        helper.registerDeserializer(ActionConstants.POP_PBB_CODE, new OF13PopPbbActionDeserializer());
+        helper.registerDeserializer(ActionConstants.POP_PBB_CODE,
+            new EmptyActionDeserializer<>(new PopPbbCaseBuilder().build()));
     }
 }
@@ -16,13 +16,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1
 /**
  * Common class for AbstractActionDeserializers which do not carry any data beyond the header.
  */
-public abstract class AbstractEmptyActionDeserializer<T extends ActionChoice> extends AbstractActionDeserializer<T> {
-    protected AbstractEmptyActionDeserializer(final @NonNull T emptyChoice) {
+public final class EmptyActionDeserializer<T extends ActionChoice> extends AbstractActionDeserializer<T> {
+    public EmptyActionDeserializer(final @NonNull T emptyChoice) {
         super(emptyChoice);
     }
 
     @Override
-    public final Action deserialize(final ByteBuf input) {
+    public Action deserialize(final ByteBuf input) {
         input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER);
         return deserializeHeader(input);
     }
diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java
deleted file mode 100644 (file)
index 06fa321..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2013 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.impl.deserialization.action;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder;
-
-/**
- * OF10StripVlanActionDeserializer.
- *
- * @author michal.polkorab
- */
-public class OF10StripVlanActionDeserializer extends AbstractEmptyActionDeserializer<StripVlanCase> {
-    public OF10StripVlanActionDeserializer() {
-        super(new StripVlanCaseBuilder().build());
-    }
-}
diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java
deleted file mode 100644 (file)
index b9f81d1..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2013 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.impl.deserialization.action;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;
-
-/**
- * OF13CopyTtlInActionDeserializer.
- *
- * @author michal.polkorab
- */
-public class OF13CopyTtlInActionDeserializer extends AbstractEmptyActionDeserializer<CopyTtlInCase> {
-    public OF13CopyTtlInActionDeserializer() {
-        super(new CopyTtlInCaseBuilder().build());
-    }
-}
diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java
deleted file mode 100644 (file)
index d952519..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2013 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.impl.deserialization.action;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;
-
-/**
- * OF13CopyTtlOutActionDeserializer.
- *
- * @author michal.polkorab
- */
-public class OF13CopyTtlOutActionDeserializer extends AbstractEmptyActionDeserializer<CopyTtlOutCase> {
-    public OF13CopyTtlOutActionDeserializer() {
-        super(new CopyTtlOutCaseBuilder().build());
-    }
-}
diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java
deleted file mode 100644 (file)
index de8cd22..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2013 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.impl.deserialization.action;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder;
-
-/**
- * OF13DecMplsTtlActionDeserializer.
- *
- * @author michal.polkorab
- */
-public class OF13DecMplsTtlActionDeserializer extends AbstractEmptyActionDeserializer<DecMplsTtlCase> {
-    public OF13DecMplsTtlActionDeserializer() {
-        super(new DecMplsTtlCaseBuilder().build());
-    }
-}
diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java
deleted file mode 100644 (file)
index 6672d67..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2013 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.impl.deserialization.action;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder;
-
-/**
- * OF13DecNwTtlActionDeserializer.
- *
- * @author michal.polkorab
- */
-public class OF13DecNwTtlActionDeserializer extends AbstractEmptyActionDeserializer<DecNwTtlCase> {
-    public OF13DecNwTtlActionDeserializer() {
-        super(new DecNwTtlCaseBuilder().build());
-    }
-}
diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java
deleted file mode 100644 (file)
index 226d4ea..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2013 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.impl.deserialization.action;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;
-
-/**
- * OF13PopPbbActionDeserializer.
- *
- * @author michal.polkorab
- */
-public class OF13PopPbbActionDeserializer extends AbstractEmptyActionDeserializer<PopPbbCase> {
-    public OF13PopPbbActionDeserializer() {
-        super(new PopPbbCaseBuilder().build());
-    }
-}
diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java
deleted file mode 100644 (file)
index e0fde70..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2013 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.impl.deserialization.action;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder;
-
-/**
- * OF13PopVlanActionDeserializer.
- *
- * @author michal.polkorab
- */
-public class OF13PopVlanActionDeserializer extends AbstractEmptyActionDeserializer<PopVlanCase> {
-    public OF13PopVlanActionDeserializer() {
-        super(new PopVlanCaseBuilder().build());
-    }
-}