[ONOS-6952] support for *(asterisk) as enum name.

Change-Id: Ia2bb862beccfd916136c81c20a310d197181ba29
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntax.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntax.java
index 87724bc..2fed4fb 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntax.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaIdentifierSyntax.java
@@ -32,6 +32,7 @@
 import java.util.List;
 
 import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
+import static org.onosproject.yang.compiler.utils.UtilConstants.ASTERISK;
 import static org.onosproject.yang.compiler.utils.UtilConstants.COLON;
 import static org.onosproject.yang.compiler.utils.UtilConstants.DEFAULT_BASE_PKG;
 import static org.onosproject.yang.compiler.utils.UtilConstants.HYPHEN;
@@ -132,7 +133,12 @@
      */
     public static String getEnumJavaAttribute(String name) {
 
-        name = name.replaceAll(REGEX_WITH_ALL_SPECIAL_CHAR, COLON);
+        if (name.equals("*")) {
+            name = ASTERISK;
+        } else {
+            name = name.replaceAll(REGEX_WITH_ALL_SPECIAL_CHAR, COLON);
+        }
+
         String[] strArray = name.split(COLON);
         StringBuilder output = new StringBuilder();
         if (strArray[0].isEmpty()) {
diff --git a/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java b/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java
index ec09187..5592395 100644
--- a/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java
+++ b/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java
@@ -1954,6 +1954,7 @@
     public static final String STRING_JOINER_CLASS = "StringJoiner";
     public static final String AUGMENTABLE = "Augmentable";
     public static final String RPC_SERVICE = "RpcService";
+    public static final String ASTERISK = "asterisk";
 
     public static final String IDENTITY = "_identity";
     public static final String TYPEDEF = "_typedef";
diff --git a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ChoiceCaseTranslatorTest.java b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ChoiceCaseTranslatorTest.java
index 8520e63..ce56863 100644
--- a/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ChoiceCaseTranslatorTest.java
+++ b/compiler/plugin/maven/src/test/java/org/onosproject/yang/compiler/plugin/maven/ChoiceCaseTranslatorTest.java
@@ -91,4 +91,27 @@
         YangPluginConfig.compileCode(COMP);
         YangIoUtils.deleteDirectory(DIR);
     }
+
+    @Test
+    public void processEnumwithNameAstrick() throws IOException,
+            ParserException, MojoExecutionException {
+        YangIoUtils.deleteDirectory(DIR);
+        String searchDir = "src/test/resources/asteriskTranslator";
+
+        Set<Path> paths = new HashSet<>();
+        for (String file : getYangFiles(searchDir)) {
+            paths.add(Paths.get(file));
+        }
+
+        utilManager.createYangFileInfoSet(paths);
+        utilManager.parseYangFileInfoSet();
+        utilManager.createYangNodeSet();
+        utilManager.resolveDependenciesUsingLinker();
+
+        YangPluginConfig yangPluginConfig = new YangPluginConfig();
+        yangPluginConfig.setCodeGenDir(DIR);
+        utilManager.translateToJava(yangPluginConfig);
+        YangPluginConfig.compileCode(COMP);
+        YangIoUtils.deleteDirectory(DIR);
+    }
 }
diff --git a/compiler/plugin/maven/src/test/resources/asteriskTranslator/Test.yang b/compiler/plugin/maven/src/test/resources/asteriskTranslator/Test.yang
new file mode 100644
index 0000000..79dfc94
--- /dev/null
+++ b/compiler/plugin/maven/src/test/resources/asteriskTranslator/Test.yang
@@ -0,0 +1,15 @@
+module Test {
+    yang-version 1;
+    namespace "http://huawei.com";
+    prefix Ant;
+
+     leaf myenum {
+         type enumeration {
+             enum *;
+             enum one;
+             enum seven {
+                 value 7;
+             }
+         }
+     }
+}
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilderTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilderTest.java
index d32eeb9..480b753 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilderTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilderTest.java
@@ -94,6 +94,7 @@
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LEAF10;
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LEAF11;
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LEAF12;
+import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LEAF13;
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LEAF2;
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LEAF3;
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LEAF4;
@@ -106,6 +107,7 @@
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LL10;
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LL11;
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LL12;
+import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LL13;
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LL2;
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LL3;
 import static org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.YtbDataTypes.LeafIdentifier.LL4;
@@ -119,10 +121,10 @@
 import static org.onosproject.yang.model.DataNode.Type.MULTI_INSTANCE_NODE;
 import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE;
 import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_NODE;
-import static org.onosproject.yang.runtime.impl.TestUtils.validateDataNode;
-import static org.onosproject.yang.runtime.impl.TestUtils.validateLeafDataNode;
 import static org.onosproject.yang.runtime.impl.MockYangSchemaNodeProvider.processSchemaRegistry;
 import static org.onosproject.yang.runtime.impl.MockYangSchemaNodeProvider.registry;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateDataNode;
+import static org.onosproject.yang.runtime.impl.TestUtils.validateLeafDataNode;
 
 /*
  *
@@ -1365,6 +1367,8 @@
                          SINGLE_INSTANCE_LEAF_VALUE_NODE, true, null);
         validateDataNode(it.next(), "leaf12", ns,
                          SINGLE_INSTANCE_LEAF_VALUE_NODE, true, "11011");
+        validateDataNode(it.next(), "leaf13", ns,
+                         SINGLE_INSTANCE_LEAF_VALUE_NODE, true, "*");
         validateDataNode(it.next(), "ll1", ns,
                          MULTI_INSTANCE_LEAF_VALUE_NODE, true, "leaf-list1");
         validateDataNode(it.next(), "ll1", ns,
@@ -1405,6 +1409,8 @@
                          MULTI_INSTANCE_LEAF_VALUE_NODE, true, "11011");
         validateDataNode(it.next(), "ll12", ns,
                          MULTI_INSTANCE_LEAF_VALUE_NODE, true, "110111");
+        validateDataNode(it.next(), "ll13", ns,
+                         MULTI_INSTANCE_LEAF_VALUE_NODE, true, "*");
         return it;
     }
 
@@ -1420,6 +1426,8 @@
         Def1Union union = new Def1Union(of(1000));
         Def1 def1 = new Def1(union);
         Def1Union union2 = new Def1Union(of(10));
+        Def1Union union22 = new Def1Union(of(10000));
+        Def1 def11 = new Def1(union22);
         Def1 def12 = new Def1(union2);
         byte[] arr = Base64.getDecoder().decode("MTEwMTE=");
         byte[] arr1 = Base64.getDecoder().decode("MTEwMTEx");
@@ -1444,6 +1452,7 @@
         cont1.leaf10(def3);
         cont1.leaf11(true);
         cont1.leaf12(arr);
+        cont1.leaf13(def11);
         cont1.addToLl1("leaf-list1");
         cont1.addToLl1("leaf-list1-2");
         cont1.addToLl2(def1);
@@ -1468,6 +1477,7 @@
         cont1.addToLl11(true);
         cont1.addToLl12(arr);
         cont1.addToLl12(arr1);
+        cont1.addToLl13(def11);
         cont1.cont2(cont2);
         data.addModelObject((ModelObject) cont1);
         return data;
@@ -1485,6 +1495,8 @@
         Def1Union union = new Def1Union(of(1000));
         Def1 def1 = new Def1(union);
         Def1Union union2 = new Def1Union(of(10));
+        Def1Union union22 = new Def1Union(of(10000));
+        Def1 def11 = new Def1(union22);
         Def1 def12 = new Def1(union2);
         byte[] arr = Base64.getDecoder().decode("MTEwMTE=");
         byte[] arr1 = Base64.getDecoder().decode("MTEwMTEx");
@@ -1508,6 +1520,7 @@
         augC.leaf10(def3);
         augC.leaf11(true);
         augC.leaf12(arr);
+        augC.leaf13(def11);
         augC.addToLl1("leaf-list1");
         augC.addToLl1("leaf-list1-2");
         augC.addToLl2(def1);
@@ -1532,6 +1545,7 @@
         augC.addToLl11(true);
         augC.addToLl12(arr);
         augC.addToLl12(arr1);
+        augC.addToLl13(def11);
         cont2.addAugmentation((InnerModelObject) augC);
         return cont2;
     }
@@ -1549,6 +1563,8 @@
 
         Def1Union union = new Def1Union(of("thousand"));
         Def1 def1 = new Def1(union);
+        Def1Union union22 = new Def1Union(of("*"));
+        Def1 def11 = new Def1(union22);
         data = addLeafModelObject(LEAF2, def1, data);
 
         byte[] arr = Base64.getDecoder().decode("MTEwMTE=");
@@ -1576,6 +1592,8 @@
 
         data = addLeafModelObject(LEAF12, arr, data);
 
+        data = addLeafModelObject(LEAF13, def11, data);
+
         List<Object> objs = new LinkedList<>();
         objs.add("leaf-list1");
         objs.add("leaf-list1-2");
@@ -1643,6 +1661,9 @@
         objs.add(arr1);
         data = addLeafListModelObject(LL12, objs, data);
 
+        objs = new LinkedList<>();
+        objs.add(def11);
+        data = addLeafListModelObject(LL13, objs, data);
         return data;
     }
 
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobSimpleDataTypeTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobSimpleDataTypeTest.java
index 46779de..7eedef0 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobSimpleDataTypeTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/YobSimpleDataTypeTest.java
@@ -20,6 +20,7 @@
 import org.onosproject.yang.gen.v1.simpledatatypes.rev20131112.simpledatatypes.DefaultCont;
 import org.onosproject.yang.gen.v1.simpledatatypes.rev20131112.simpledatatypes.gr.Cont3;
 import org.onosproject.yang.gen.v1.simpledatatypesll.rev20131112.simpledatatypesll.DefaultCont1;
+import org.onosproject.yang.gen.v1.simpledatatypesll.rev20131112.simpledatatypesll.cont1.Lfenum2Enum;
 import org.onosproject.yang.gen.v1.ytbdatatypes.rev20160826.ytbdatatypes.Leaf7;
 import org.onosproject.yang.model.DataNode;
 import org.onosproject.yang.model.DataNode.Builder;
@@ -34,6 +35,7 @@
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
+import static org.onosproject.yang.gen.v1.simpledatatypes.rev20131112.simpledatatypes.tpdfun0.Tpdfun0Enum.ASTERISK;
 import static org.onosproject.yang.gen.v1.simpledatatypes.rev20131112.simpledatatypes.tpdfun0.Tpdfun0Enum.SUCCESSFUL_EXIT;
 import static org.onosproject.yang.gen.v1.simpledatatypesll.rev20131112.simpledatatypesll.cont1.Lfenum1Enum.GRACE_PERIOD_EXPIRED;
 import static org.onosproject.yang.runtime.SerializerHelper.addDataNode;
@@ -229,6 +231,10 @@
         dBlr = addDataNode(dBlr, "lfenum1", DATA_TYPE_NAME_SPACE, value, null);
         dBlr = exitDataNode(dBlr);
 
+        value = "*";
+        dBlr = addDataNode(dBlr, "lfenum2", DATA_TYPE_NAME_SPACE, value, null);
+        dBlr = exitDataNode(dBlr);
+
         value = "/cont";
         dBlr = addDataNode(dBlr, "inst-iden", DATA_TYPE_NAME_SPACE, value, null);
         dBlr = exitDataNode(dBlr);
@@ -610,6 +616,11 @@
         value = "grace period expired";
         dBlr = addDataNode(dBlr, "lfenum1", null, value, null);
         dBlr = exitDataNode(dBlr);
+
+        value = "*";
+        dBlr = addDataNode(dBlr, "lfenum2", null, value, null);
+        dBlr = exitDataNode(dBlr);
+
         dBlr = exitDataNode(dBlr);
 
         return dBlr.build();
@@ -685,6 +696,7 @@
         assertThat(cont.identityref1().getSimpleName(), is("Iden"));
         assertThat(cont.identityref2().getSimpleName(), is("Pro"));
         assertThat(cont.lfenum1().enumeration(), is(SUCCESSFUL_EXIT));
+        assertThat(cont.lfenum2().enumeration(), is(ASTERISK));
         assertThat(cont.instIden(), is("/cont"));
         value = 8;
         assertThat(cont.lref1(), is(value));
@@ -842,5 +854,6 @@
         assertThat(cont.identityref1().get(0).getSimpleName().toString(),
                    is("Iden"));
         assertThat(cont.lfenum1().get(0), is(GRACE_PERIOD_EXPIRED));
+        assertThat(cont.lfenum2().get(0), is(Lfenum2Enum.ASTERISK));
     }
 }
diff --git a/runtime/src/test/resources/yobTestYangFiles/simple-data-types-leaf-list.yang b/runtime/src/test/resources/yobTestYangFiles/simple-data-types-leaf-list.yang
index fa85b57..ab56909 100644
--- a/runtime/src/test/resources/yobTestYangFiles/simple-data-types-leaf-list.yang
+++ b/runtime/src/test/resources/yobTestYangFiles/simple-data-types-leaf-list.yang
@@ -263,5 +263,15 @@
             }
         }
     }
+    leaf-list lfenum2 {
+        type enumeration {
+            enum "successful exit" {
+                value 1;
+            }
+            enum "*" {
+                value 3;
+            }
+        }
+    }
   }
 }
diff --git a/runtime/src/test/resources/yobTestYangFiles/simple-data-types.yang b/runtime/src/test/resources/yobTestYangFiles/simple-data-types.yang
index d401a9c..cacff6c 100644
--- a/runtime/src/test/resources/yobTestYangFiles/simple-data-types.yang
+++ b/runtime/src/test/resources/yobTestYangFiles/simple-data-types.yang
@@ -67,6 +67,9 @@
             enum "grace period expired" {
                 value 2;
             }
+            enum "*" {
+                value 3;
+            }
         }
     }
 
@@ -305,6 +308,10 @@
             type tpdfun0;
         }
 
+        leaf lfenum2 {
+            type tpdfun0;
+        }
+
         leaf inst-iden {
             type instance-identifier;
         }
diff --git a/runtime/src/test/resources/ytbTestYangFiles/YtbDataTypes.yang b/runtime/src/test/resources/ytbTestYangFiles/YtbDataTypes.yang
index b966b8f..92818c1 100644
--- a/runtime/src/test/resources/ytbTestYangFiles/YtbDataTypes.yang
+++ b/runtime/src/test/resources/ytbTestYangFiles/YtbDataTypes.yang
@@ -18,6 +18,9 @@
                 enum thousand {
                     value "1000";
                 }
+                enum * {
+                    value "10000";
+                }
             }
         }
     }
@@ -114,6 +117,10 @@
         type def5;
     }
 
+    leaf leaf13 {
+        type def1;
+    }
+
     container cont1 {
         leaf leaf1 {
             type string;
@@ -173,6 +180,10 @@
             type def5;
         }
 
+        leaf leaf13 {
+            type def1;
+        }
+
         leaf-list ll1 {
             type string;
         }
@@ -231,6 +242,10 @@
             type def5;
         }
 
+        leaf-list ll13 {
+            type def1;
+        }
+
         container cont2 {
         }
     }
@@ -293,6 +308,10 @@
         type def5;
     }
 
+    leaf-list ll13 {
+        type def1;
+    }
+
     augment "/cont1/cont2" {
         leaf leaf1 {
             type string;
@@ -352,6 +371,10 @@
             type def5;
         }
 
+        leaf leaf13 {
+            type def1;
+        }
+
         leaf-list ll1 {
             type string;
         }
@@ -409,5 +432,9 @@
         leaf-list ll12 {
             type def5;
         }
+
+        leaf-list ll13 {
+            type def1;
+        }
     }
 }