HONEYCOMB-145 - Utility Class Refactoring
[honeycomb.git] / vpp-common / vpp-translate-utils / src / main / java / io / fd / honeycomb / translate / v3po / util / TagRewriteOperation.java
index 7958aff..e7c07ed 100644 (file)
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package io.fd.honeycomb.translate.v3po.util;
 
 import com.google.common.base.Preconditions;
@@ -21,9 +22,9 @@ import javax.annotation.Nonnegative;
 import javax.annotation.Nullable;
 
 /**
- * Defines vlan tag rewrite config options for VPP
- *
- * TODO corresponding enum (defined in l2_vtr.h) should be defined in vpe.api
+ * Defines vlan tag rewrite config options for VPP.
+ * <p/>
+ * TODO HONEYCOMB-184 corresponding enum (defined in l2_vtr.h) should be defined in vpe.api
  * (does vpp's IDL support enum type definition?)
  * which would allow to generate this class in jvpp
  */
@@ -38,7 +39,12 @@ public enum TagRewriteOperation {
     translate_2_to_1(2),
     translate_2_to_2(2);
 
-    private final static int MAX_INDEX = 3;
+    private static final int MAX_INDEX = 3;
+    private static TagRewriteOperation[][] translation = new TagRewriteOperation[][]{
+            {disabled, push_1, push_2},
+            {pop_1, translate_1_to_1, translate_1_to_2},
+            {pop_2, translate_2_to_1, translate_2_to_2}
+    };
     private final int code;
     private final byte popTags;
 
@@ -47,15 +53,10 @@ public enum TagRewriteOperation {
         this.popTags = UnsignedBytes.checkedCast(popTags);
     }
 
-    private static TagRewriteOperation[][] translation = new TagRewriteOperation[][] {
-        {disabled, push_1, push_2},
-        {pop_1, translate_1_to_1, translate_1_to_2},
-        {pop_2, translate_2_to_1, translate_2_to_2}
-    };
-
     /**
      * Returns VPP tag rewrite operation for given number of tags to pop and tags to push.
-     * @param toPop number of tags to pop (0..2)
+     *
+     * @param toPop  number of tags to pop (0..2)
      * @param toPush number of tags to push (0..2)
      * @return vpp tag rewrite operation for given input parameters
      */
@@ -67,13 +68,14 @@ public enum TagRewriteOperation {
 
     /**
      * Returns VPP tag rewrite operation for given operation code.
+     *
      * @param code VPP tag rewrite operation code
      * @return vpp tag rewrite operation for given input parameter
      */
     @Nullable
     public static TagRewriteOperation get(@Nonnegative final int code) {
         for (TagRewriteOperation operation : TagRewriteOperation.values()) {
-            if (code == operation.code){
+            if (code == operation.code) {
                 return operation;
             }
         }