[ONOS-4412]Defect fix for uppercase presence in identifier
Change-Id: Iee7f6a47230652833799e0303606d786d55f5dd8
diff --git a/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/AugmentJavaFileNameGenUtil.java b/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/AugmentJavaFileNameGenUtil.java
index 113138f..730923a 100644
--- a/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/AugmentJavaFileNameGenUtil.java
+++ b/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/AugmentJavaFileNameGenUtil.java
@@ -21,7 +21,7 @@
import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
/**
* Represents a utility which provides valid name for generated java file for augment node.
@@ -110,9 +110,9 @@
*/
private static String createName(YangNodeIdentifier nodeId, boolean isPrefix) {
if (isPrefix) {
- return AUGMENTED + getCaptialCase(nodeId.getPrefix()) + getCaptialCase(nodeId.getName());
+ return AUGMENTED + getCapitalCase(nodeId.getPrefix()) + getCapitalCase(nodeId.getName());
} else {
- return AUGMENTED + getCaptialCase(nodeId.getName());
+ return AUGMENTED + getCapitalCase(nodeId.getName());
}
}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java b/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
index bcfdf80..b0a65a4 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
@@ -57,10 +57,9 @@
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getParentNodeInGenCode;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod;
@@ -382,7 +381,7 @@
* @return mapped Java class name
*/
String getGeneratedJavaClassName() {
- return getJavaFileInfo().getJavaName();
+ return getCapitalCase(getJavaFileInfo().getJavaName());
}
/**
@@ -865,8 +864,9 @@
appendToFile(getGetterImplTempFileHandle(), getOverRideString() + getGetterForClass(attr,
getGeneratedJavaFiles()) + NEW_LINE);
} else {
- appendToFile(getGetterImplTempFileHandle(), getJavaDoc(GETTER_METHOD, attr.getAttributeName(), false)
- + getGetterForClass(attr, getGeneratedJavaFiles()) + NEW_LINE);
+ appendToFile(getGetterImplTempFileHandle(),
+ getJavaDoc(GETTER_METHOD, getCapitalCase(attr.getAttributeName()), false)
+ + getGetterForClass(attr, getGeneratedJavaFiles()) + NEW_LINE);
}
}
@@ -1034,7 +1034,7 @@
/*
* TODO: check if this utility needs to be called or move to the caller
*/
- String attributeName = getCamelCase(getSmallCase(attr.getAttributeName()), null);
+ String attributeName = getCamelCase(attr.getAttributeName(), null);
if (attr.isQualifiedName()) {
return getJavaAttributeDefination(attr.getImportInfo().getPkgInfo(),
attr.getImportInfo().getClassInfo(),
@@ -1104,7 +1104,7 @@
* generated java files or qualified access
*/
JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(parentNode,
- curNodeName);
+ getCapitalCase(curNodeName));
if (!(parentNode instanceof TempJavaCodeFragmentFilesContainer)) {
throw new TranslatorException("Parent node does not have file info");
}
@@ -1156,7 +1156,7 @@
throw new TranslatorException("missing java file information to get the package details "
+ "of attribute corresponding to child node");
}
- caseImportInfo.setClassInfo(getCaptialCase(getCamelCase(parent.getName(), null)));
+ caseImportInfo.setClassInfo(getCapitalCase(getCamelCase(parent.getName(), null)));
caseImportInfo.setPkgInfo(((JavaFileInfoContainer) parent).getJavaFileInfo().getPackage());
((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
.getBeanTempFiles().getJavaImportData().addImportInfo(caseImportInfo);
@@ -1298,7 +1298,7 @@
* @return java class name
*/
String getJavaClassName(String suffix) {
- return getCaptialCase(getJavaFileInfo().getJavaName()) + suffix;
+ return getCapitalCase(getJavaFileInfo().getJavaName()) + suffix;
}
/**
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java b/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java
index 288f640..4fe9cd6 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java
@@ -28,6 +28,7 @@
import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefClose;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateManagerClassFile;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateServiceInterfaceFile;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcManagerMethod;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcServiceMethod;
import static org.onosproject.yangutils.translator.tojava.utils.TempJavaCodeFragmentFilesUtils.addArrayListImport;
@@ -235,10 +236,10 @@
String rpcInput = EMPTY_STRING;
String rpcOutput = VOID;
if (javaAttributeInfoOfInput != null) {
- rpcInput = javaAttributeInfoOfInput.getAttributeName();
+ rpcInput = getCapitalCase(javaAttributeInfoOfInput.getAttributeName());
}
if (javaAttributeInfoOfOutput != null) {
- rpcOutput = javaAttributeInfoOfOutput.getAttributeName();
+ rpcOutput = getCapitalCase(javaAttributeInfoOfOutput.getAttributeName());
}
appendToFile(getRpcInterfaceTempFileHandle(), generateJavaDocForRpc(rpcName, RPC_INPUT_VAR_NAME, rpcOutput)
+ getRpcServiceMethod(rpcName, rpcInput, rpcOutput) + NEW_LINE);
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
index b743773..d2132f0 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
@@ -37,6 +37,7 @@
import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getParentNodeInGenCode;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo;
@@ -157,7 +158,7 @@
* generated java files or qualified access
*/
JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(currentNode,
- childNodeName);
+ getCapitalCase(childNodeName));
if (!(parentNode instanceof TempJavaCodeFragmentFilesContainer)) {
throw new TranslatorException("Parent node does not have file info");
}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java
index 5c3a144..9e46aef 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java
@@ -24,6 +24,7 @@
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
/**
@@ -85,7 +86,7 @@
public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() {
if (tempFileHandle == null) {
throw new RuntimeException("Missing temp file hand for current node "
- + getJavaFileInfo().getJavaName());
+ + getCapitalCase(getJavaFileInfo().getJavaName()));
}
return tempFileHandle;
}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
index 606fc3d..f5c6bdc 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
@@ -31,7 +31,7 @@
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUnion;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE;
import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER;
@@ -189,7 +189,7 @@
case BOOLEAN:
return BOOLEAN_WRAPPER;
case ENUMERATION:
- return getCaptialCase(
+ return getCapitalCase(
getCamelCase(((YangJavaEnumeration) yangType.getDataTypeExtendedInfo()).getName(), null));
case BITS:
//TODO:BITS
@@ -206,12 +206,12 @@
case EMPTY:
return BOOLEAN_WRAPPER;
case UNION:
- return getCaptialCase(getCamelCase(((YangJavaUnion) yangType.getDataTypeExtendedInfo()).getName(),
+ return getCapitalCase(getCamelCase(((YangJavaUnion) yangType.getDataTypeExtendedInfo()).getName(),
null));
case INSTANCE_IDENTIFIER:
//TODO:INSTANCE_IDENTIFIER
case DERIVED:
- return getCaptialCase(getCamelCase(yangType.getDataTypeName(), null));
+ return getCapitalCase(getCamelCase(yangType.getDataTypeName(), null));
default:
throw new TranslatorException("given data type is not supported.");
}
@@ -225,7 +225,7 @@
case STRING:
return STRING_DATA_TYPE;
case ENUMERATION:
- return getCaptialCase(
+ return getCapitalCase(
getCamelCase(((YangJavaEnumeration) yangType.getDataTypeExtendedInfo()).getName(), null));
case BITS:
//TODO:BITS
@@ -243,13 +243,13 @@
//TODO:EMPTY
break;
case UNION:
- return getCaptialCase(getCamelCase(((YangJavaUnion) yangType.getDataTypeExtendedInfo()).getName(),
+ return getCapitalCase(getCamelCase(((YangJavaUnion) yangType.getDataTypeExtendedInfo()).getName(),
null));
case INSTANCE_IDENTIFIER:
//TODO:INSTANCE_IDENTIFIER
break;
case DERIVED:
- return getCaptialCase(getCamelCase(yangType.getDataTypeName(), null));
+ return getCapitalCase(getCamelCase(yangType.getDataTypeName(), null));
default:
return null;
}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
index 3edf5c0..c0cf209 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
@@ -57,8 +57,7 @@
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getEnumsValueAttribute;
import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentInfoListImpl;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart;
@@ -171,7 +170,7 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCaptialCase(javaFileInfo.getJavaName());
+ String className = getCapitalCase(javaFileInfo.getJavaName());
String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
initiateJavaFileGeneration(file, className, INTERFACE_MASK, imports, path);
@@ -209,7 +208,7 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCaptialCase(javaFileInfo.getJavaName());
+ String className = getCapitalCase(javaFileInfo.getJavaName());
String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
initiateJavaFileGeneration(file, className, BUILDER_INTERFACE_MASK, null, path);
@@ -268,7 +267,7 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCaptialCase(javaFileInfo.getJavaName());
+ String className = getCapitalCase(javaFileInfo.getJavaName());
String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
initiateJavaFileGeneration(file, className, BUILDER_CLASS_MASK, imports, path);
@@ -343,7 +342,7 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCaptialCase(javaFileInfo.getJavaName());
+ String className = getCapitalCase(javaFileInfo.getJavaName());
String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
initiateJavaFileGeneration(file, className, GENERATE_SERVICE_AND_MANAGER, imports, path);
@@ -407,7 +406,7 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCaptialCase(javaFileInfo.getJavaName());
+ String className = getCapitalCase(javaFileInfo.getJavaName());
String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
initiateJavaFileGeneration(file, className, IMPL_CLASS_MASK, null, path);
@@ -517,7 +516,7 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCaptialCase(javaFileInfo.getJavaName());
+ String className = getCapitalCase(javaFileInfo.getJavaName());
String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
initiateJavaFileGeneration(file, className, GENERATE_TYPEDEF_CLASS, imports, path);
@@ -621,7 +620,7 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCaptialCase(javaFileInfo.getJavaName());
+ String className = getCapitalCase(javaFileInfo.getJavaName());
String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
initiateJavaFileGeneration(file, className, GENERATE_UNION_CLASS, imports, path);
@@ -725,10 +724,10 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCaptialCase(javaFileInfo.getJavaName());
+ String className = javaFileInfo.getJavaName();
String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
- initiateJavaFileGeneration(file, className, GENERATE_ENUM_CLASS, null, path);
+ initiateJavaFileGeneration(file, getCapitalCase(className), GENERATE_ENUM_CLASS, null, path);
/**
* Add attribute strings.
*/
@@ -739,7 +738,7 @@
.getTempJavaCodeFragmentFiles().getEnumerationTempFiles()), COMMA), NEW_LINE)
+ SEMI_COLAN + NEW_LINE);
} catch (IOException e) {
- throw new IOException("No data found in temporary java code fragment files for " + className
+ throw new IOException("No data found in temporary java code fragment files for " + getCapitalCase(className)
+ " while enum class file generation");
}
@@ -747,13 +746,13 @@
* Add an
* attribute to get the enum's values.
*/
- insertDataIntoJavaFile(file, getEnumsValueAttribute(className));
+ insertDataIntoJavaFile(file, getEnumsValueAttribute(getCapitalCase(className)));
/**
* Add a constructor for enum.
*/
- insertDataIntoJavaFile(file, getJavaDoc(TYPE_CONSTRUCTOR, getSmallCase(className), false)
- + getEnumsConstrcutor(className) + NEW_LINE);
+ insertDataIntoJavaFile(file, getJavaDoc(TYPE_CONSTRUCTOR, className, false)
+ + getEnumsConstrcutor(getCapitalCase(className)) + NEW_LINE);
TempJavaEnumerationFragmentFiles enumFragFiles =
((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
@@ -767,18 +766,18 @@
/**
* Add a getter method for enum.
*/
- insertDataIntoJavaFile(file, getJavaDoc(GETTER_METHOD, getSmallCase(className), false)
- + getGetter(INT, getSmallCase(className), GENERATE_ENUM_CLASS) + NEW_LINE);
+ insertDataIntoJavaFile(file, getJavaDoc(GETTER_METHOD, className, false)
+ + getGetter(INT, className, GENERATE_ENUM_CLASS) + NEW_LINE);
try {
- insertDataIntoJavaFile(file, getFromStringMethodSignature(className)
+ insertDataIntoJavaFile(file, getFromStringMethodSignature(getCapitalCase(className))
+ getDataFromTempFileHandle(FROM_STRING_IMPL_MASK,
((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
.getEnumerationTempFiles())
+ getFromStringMethodClose());
} catch (IOException e) {
- throw new IOException("No data found in temporary java code fragment files for " + className
- + " while enum class file generation");
+ throw new IOException("No data found in temporary java code fragment files for " +
+ getCapitalCase(className) + " while enum class file generation");
}
insertDataIntoJavaFile(file, CLOSE_CURLY_BRACKET + NEW_LINE);
@@ -802,7 +801,7 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCaptialCase(javaFileInfo.getJavaName()) + SERVICE_METHOD_STRING;
+ String className = getCapitalCase(javaFileInfo.getJavaName()) + SERVICE_METHOD_STRING;
String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
initiateJavaFileGeneration(file, className, GENERATE_SERVICE_AND_MANAGER, imports, path);
@@ -859,7 +858,7 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCaptialCase(javaFileInfo.getJavaName()) + EVENT_STRING;
+ String className = getCapitalCase(javaFileInfo.getJavaName()) + EVENT_STRING;
String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
initiateJavaFileGeneration(file, className, GENERATE_EVENT_CLASS, imports, path);
@@ -913,7 +912,7 @@
JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
- String className = getCaptialCase(javaFileInfo.getJavaName()) + EVENT_LISTENER_STRING;
+ String className = getCapitalCase(javaFileInfo.getJavaName()) + EVENT_LISTENER_STRING;
String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
initiateJavaFileGeneration(file, className, GENERATE_EVENT_LISTENER_INTERFACE, imports, path);
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
index 5ab0923..10ec3c2 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
@@ -17,6 +17,7 @@
package org.onosproject.yangutils.translator.tojava.utils;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.onosproject.yangutils.datamodel.YangNode;
@@ -39,6 +40,10 @@
import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_SINGLE_LETTER;
import static org.onosproject.yangutils.utils.UtilConstants.REGEX_FOR_UNDERSCORE;
import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_ALL_SPECIAL_CHAR;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_DIGITS;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_SINGLE_CAPITAL_CASE;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES;
+import static org.onosproject.yangutils.utils.UtilConstants.REGEX_WITH_UPPERCASE;
import static org.onosproject.yangutils.utils.UtilConstants.REVISION_PREFIX;
import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
import static org.onosproject.yangutils.utils.UtilConstants.UNDER_SCORE;
@@ -231,7 +236,7 @@
* Returns the YANG identifier name as java identifier.
*
* @param yangIdentifier identifier in YANG file
- * @param conflictResolver object of YANG to java naming confilct util
+ * @param conflictResolver object of YANG to java naming conflict util
* @return corresponding java identifier
*/
public static String getCamelCase(String yangIdentifier, YangToJavaNamingConflictUtil conflictResolver) {
@@ -262,7 +267,57 @@
}
strArray = stringArrangement.toArray(new String[stringArrangement.size()]);
}
- return applyCamelCaseRule(strArray);
+ return upperCaseConflictResolver(strArray);
+ }
+
+ /**
+ * Resolves the conflict when input has uppercase.
+ *
+ * @param stringArray containing strings for uppercase conflict resolver
+ * @return camel cased string
+ */
+ private static String upperCaseConflictResolver(String[] stringArray) {
+
+ for (int l = 0; l < stringArray.length; l++) {
+ String[] upperCaseSplitArray = stringArray[l].split(REGEX_WITH_UPPERCASE);
+ for (int m = 0; m < upperCaseSplitArray.length; m++) {
+ if (upperCaseSplitArray[m].matches(REGEX_WITH_SINGLE_CAPITAL_CASE)) {
+ int check = m;
+ while (check + 1 < upperCaseSplitArray.length) {
+ if (upperCaseSplitArray[check + 1].matches(REGEX_WITH_SINGLE_CAPITAL_CASE)) {
+ upperCaseSplitArray[check + 1] = upperCaseSplitArray[check + 1].toLowerCase();
+ check = check + 1;
+ } else if (upperCaseSplitArray[check + 1]
+ .matches(REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES)) {
+ upperCaseSplitArray[check + 1] = upperCaseSplitArray[check + 1].toLowerCase();
+ break;
+ } else {
+ break;
+ }
+ }
+ }
+ }
+ StringBuilder strBuilder = new StringBuilder();
+ for (String element : upperCaseSplitArray) {
+ strBuilder.append(element);
+ }
+ stringArray[l] = strBuilder.toString();
+ }
+ List<String> result = new ArrayList<String>();
+ for (String element : stringArray) {
+ String[] capitalCaseSplitArray = element.split(REGEX_WITH_UPPERCASE);
+ for (String letter : capitalCaseSplitArray) {
+ String[] arrayForAddition = letter.split(REGEX_WITH_DIGITS);
+ List<String> list = Arrays.asList(arrayForAddition);
+ for (String str : list) {
+ if (str != null && !str.isEmpty()) {
+ result.add(str);
+ }
+ }
+ }
+ }
+ stringArray = result.toArray(new String[result.size()]);
+ return applyCamelCaseRule(stringArray);
}
/**
@@ -270,11 +325,11 @@
* the letter next to a number in an array.
*
* @param stringArray containing strings for camel case separation
- * @return camel cased string
+ * @return camel case rule checked string
*/
- public static String applyCamelCaseRule(String[] stringArray) {
+ private static String applyCamelCaseRule(String[] stringArray) {
- String ruleChecker = stringArray[0];
+ String ruleChecker = stringArray[0].toLowerCase();
int i;
if (ruleChecker.matches(REGEX_FOR_FIRST_DIGIT)) {
i = 0;
@@ -286,7 +341,7 @@
if ((i + 1) == stringArray.length) {
if (stringArray[i].matches(REGEX_FOR_SINGLE_LETTER)
|| stringArray[i].matches(REGEX_FOR_DIGITS_WITH_SINGLE_LETTER)) {
- ruleChecker = ruleChecker + stringArray[i];
+ ruleChecker = ruleChecker + stringArray[i].toLowerCase();
break;
}
}
@@ -311,19 +366,19 @@
/**
* Adds prefix YANG auto prefix if the string begins with digit or is a java key word.
*
- * @param camelCasePrefixer string for adding prefix
+ * @param camelCasePrefix string for adding prefix
* @return prefixed camel case string
*/
- public static String addPrefix(String camelCasePrefixer) {
+ private static String addPrefix(String camelCasePrefix) {
- if (camelCasePrefixer.matches(REGEX_FOR_FIRST_DIGIT)) {
- camelCasePrefixer = YANG_AUTO_PREFIX + camelCasePrefixer;
+ if (camelCasePrefix.matches(REGEX_FOR_FIRST_DIGIT)) {
+ camelCasePrefix = YANG_AUTO_PREFIX + camelCasePrefix;
}
- if (JAVA_KEY_WORDS.contains(camelCasePrefixer)) {
- camelCasePrefixer = YANG_AUTO_PREFIX + camelCasePrefixer.substring(0, 1).toUpperCase()
- + camelCasePrefixer.substring(1);
+ if (JAVA_KEY_WORDS.contains(camelCasePrefix.toLowerCase())) {
+ camelCasePrefix = YANG_AUTO_PREFIX + camelCasePrefix.substring(0, 1).toUpperCase()
+ + camelCasePrefix.substring(1);
}
- return camelCasePrefixer;
+ return camelCasePrefix;
}
/**
@@ -332,7 +387,7 @@
* @param consecCapitalCaseRemover which requires the restriction of consecutive capital case
* @return string without consecutive capital case
*/
- public static String restrictConsecutiveCapitalCase(String consecCapitalCaseRemover) {
+ private static String restrictConsecutiveCapitalCase(String consecCapitalCaseRemover) {
for (int k = 0; k < consecCapitalCaseRemover.length(); k++) {
if (k + 1 < consecCapitalCaseRemover.length()) {
@@ -350,13 +405,14 @@
/**
* Returns the YANG identifier name as java identifier with first letter
- * in caps.
+ * in capital.
*
* @param yangIdentifier identifier in YANG file
* @return corresponding java identifier
*/
- public static String getCaptialCase(String yangIdentifier) {
- return yangIdentifier.substring(0, 1).toUpperCase() + yangIdentifier.substring(1);
+ public static String getCapitalCase(String yangIdentifier) {
+ yangIdentifier = yangIdentifier.substring(0, 1).toUpperCase() + yangIdentifier.substring(1);
+ return restrictConsecutiveCapitalCase(yangIdentifier);
}
/**
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
index b98b71c..333361f 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
@@ -25,7 +25,7 @@
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getParseFromStringMethod;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.AND;
@@ -141,7 +141,7 @@
public static String getGetterString(JavaAttributeInfo attr, int generatedJavaFiles) {
String returnType = getReturnType(attr);
- String attributeName = getSmallCase(attr.getAttributeName());
+ String attributeName = attr.getAttributeName();
return getJavaDoc(GETTER_METHOD, attributeName, attr.isListAttr())
+ getGetterForInterface(attributeName, returnType, attr.isListAttr(), generatedJavaFiles);
@@ -158,7 +158,7 @@
public static String getSetterString(JavaAttributeInfo attr, String className, int generatedJavaFiles) {
String attrType = getReturnType(attr);
- String attributeName = getSmallCase(attr.getAttributeName());
+ String attributeName = attr.getAttributeName();
JavaDocGen.JavaDocType type;
if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
type = MANAGER_SETTER_METHOD;
@@ -223,7 +223,7 @@
public static String getGetterForClass(JavaAttributeInfo attr, int generatedJavaFiles) {
String attrQuaifiedType = getReturnType(attr);
- String attributeName = getSmallCase(attr.getAttributeName());
+ String attributeName = attr.getAttributeName();
if (!attr.isListAttr()) {
return getGetter(attrQuaifiedType, attributeName, generatedJavaFiles);
@@ -242,7 +242,7 @@
*/
public static String getGetter(String type, String name, int generatedJavaFiles) {
if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) {
- return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + type + SPACE + GET_METHOD_PREFIX + getCaptialCase(name)
+ return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + type + SPACE + GET_METHOD_PREFIX + getCapitalCase(name)
+ OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE +
EIGHT_SPACE_INDENTATION + YANG_UTILS_TODO + NEW_LINE + EIGHT_SPACE_INDENTATION +
RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
@@ -266,7 +266,7 @@
public static String getSetterForClass(JavaAttributeInfo attr, String className, int generatedJavaFiles) {
String attrQuaifiedType = getReturnType(attr);
- String attributeName = getSmallCase(attr.getAttributeName());
+ String attributeName = attr.getAttributeName();
if (!attr.isListAttr()) {
return getSetter(className, attributeName, attrQuaifiedType, generatedJavaFiles);
}
@@ -285,7 +285,7 @@
private static String getSetter(String className, String name, String type, int generatedJavaFiles) {
if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) {
return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX
- + getCaptialCase(name) + OPEN_PARENTHESIS + type + SPACE + name + CLOSE_PARENTHESIS + SPACE +
+ + getCapitalCase(name) + OPEN_PARENTHESIS + type + SPACE + name + CLOSE_PARENTHESIS + SPACE +
OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + YANG_UTILS_TODO +
NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
} else {
@@ -306,7 +306,7 @@
public static String getSetterForTypeDefClass(JavaAttributeInfo attr) {
String attrQuaifiedType = getReturnType(attr);
- String attributeName = getSmallCase(attr.getAttributeName());
+ String attributeName = attr.getAttributeName();
return getTypeDefSetter(attrQuaifiedType, attributeName);
}
@@ -318,7 +318,7 @@
* @return setter for type def's attribute
*/
private static String getTypeDefSetter(String type, String name) {
- return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX + getCaptialCase(name)
+ return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(name)
+ OPEN_PARENTHESIS + type + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
+ EIGHT_SPACE_INDENTATION + THIS + PERIOD + name + SPACE + EQUAL + SPACE + VALUE + SEMI_COLAN + NEW_LINE
+ FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
@@ -362,7 +362,7 @@
private static String getGetterInterfaceString(String returnType, String yangName,
int generatedJavaFiles) {
if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) {
- return FOUR_SPACE_INDENTATION + returnType + SPACE + GET_METHOD_PREFIX + getCaptialCase(yangName)
+ return FOUR_SPACE_INDENTATION + returnType + SPACE + GET_METHOD_PREFIX + getCapitalCase(yangName)
+ OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN;
} else {
return FOUR_SPACE_INDENTATION + returnType + SPACE + yangName
@@ -402,7 +402,7 @@
int generatedJavaFiles) {
if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) {
- return FOUR_SPACE_INDENTATION + VOID + SPACE + SET_METHOD_PREFIX + getCaptialCase(attrName)
+ return FOUR_SPACE_INDENTATION + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(attrName)
+ OPEN_PARENTHESIS + attrType + SPACE + attrName + CLOSE_PARENTHESIS + SEMI_COLAN;
} else {
return FOUR_SPACE_INDENTATION + className + BUILDER + SPACE + attrName
@@ -471,13 +471,13 @@
*/
public static String getConstructor(String yangName, JavaAttributeInfo attr, int generatedJavaFiles) {
- String attributeName = getSmallCase(attr.getAttributeName());
+ String attributeName = attr.getAttributeName();
String constructor;
if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) {
constructor = EIGHT_SPACE_INDENTATION + THIS + PERIOD + getCamelCase(attributeName, null) + SPACE + EQUAL
+ SPACE + BUILDER.toLowerCase() + OBJECT + PERIOD + GET_METHOD_PREFIX
- + getCaptialCase(getCamelCase(attributeName, null)) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS +
+ + getCapitalCase(getCamelCase(attributeName, null)) + OPEN_PARENTHESIS + CLOSE_PARENTHESIS +
SEMI_COLAN
+ NEW_LINE;
} else {
@@ -499,10 +499,10 @@
*/
public static String getRpcServiceMethod(String rpcName, String inputName, String outputName) {
- rpcName = getSmallCase(getCamelCase(rpcName, null));
- inputName = getCaptialCase(inputName);
+ rpcName = getCamelCase(rpcName, null);
+ inputName = getCapitalCase(inputName);
if (!outputName.equals(VOID)) {
- outputName = getCaptialCase(outputName);
+ outputName = getCapitalCase(outputName);
}
return FOUR_SPACE_INDENTATION + outputName + SPACE + rpcName + OPEN_PARENTHESIS + inputName + SPACE
+ RPC_INPUT_VAR_NAME + CLOSE_PARENTHESIS + SEMI_COLAN;
@@ -518,10 +518,10 @@
*/
public static String getRpcManagerMethod(String rpcName, String inputName, String outputName) {
- rpcName = getSmallCase(getCamelCase(rpcName, null));
- inputName = getCaptialCase(inputName);
+ rpcName = getCamelCase(rpcName, null);
+ inputName = getCapitalCase(inputName);
if (!outputName.equals(VOID)) {
- outputName = getCaptialCase(outputName);
+ outputName = getCapitalCase(outputName);
}
String method =
@@ -599,7 +599,7 @@
*/
public static String getToStringMethod(JavaAttributeInfo attr) {
- String attributeName = getSmallCase(attr.getAttributeName());
+ String attributeName = attr.getAttributeName();
return TWELVE_SPACE_INDENTATION + PERIOD + ADD_STRING + OPEN_PARENTHESIS + QUOTES + attributeName + QUOTES
+ COMMA + SPACE + attributeName + CLOSE_PARENTHESIS;
}
@@ -718,7 +718,7 @@
* @return hash code method
*/
public static String getHashCodeMethod(JavaAttributeInfo attr) {
- return getSmallCase(attr.getAttributeName()) + COMMA + SPACE;
+ return attr.getAttributeName() + COMMA + SPACE;
}
/**
@@ -781,7 +781,7 @@
*/
public static String getEqualsMethod(JavaAttributeInfo attr) {
- String attributeName = getSmallCase(attr.getAttributeName());
+ String attributeName = attr.getAttributeName();
return SIXTEEN_SPACE_INDENTATION + SPACE + OBJECT_STRING + SUFFIX_S + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS
+ attributeName + COMMA + SPACE + OTHER + PERIOD + attributeName + CLOSE_PARENTHESIS + SPACE + AND
+ AND;
@@ -830,7 +830,7 @@
public static String getOfMethodStringAndJavaDoc(JavaAttributeInfo attr, String generatedJavaClassName) {
String attrType = getReturnType(attr);
- String attrName = getSmallCase(attr.getAttributeName());
+ String attrName = attr.getAttributeName();
return getJavaDoc(OF_METHOD, generatedJavaClassName + " for type " + attrName, false)
+ getOfMethodString(attrType, generatedJavaClassName);
@@ -861,7 +861,7 @@
public static String getTypeConstructorStringAndJavaDoc(JavaAttributeInfo attr, String generatedJavaClassName) {
String attrType = getReturnType(attr);
- String attrName = getSmallCase(attr.getAttributeName());
+ String attrName = attr.getAttributeName();
return getJavaDoc(TYPE_CONSTRUCTOR, generatedJavaClassName + " for type " + attrName, false)
+ getTypeConstructorString(attrType, attrName, generatedJavaClassName);
@@ -938,10 +938,10 @@
public static String getEnumsOfMethod(String className, JavaAttributeInfo attr,
Map<String, Integer> enumMap, List<String> enumList) {
String attrType = getReturnType(attr);
- String attrName = getSmallCase(attr.getAttributeName());
+ String attrName = attr.getAttributeName();
- String method = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STATIC + SPACE + className + SPACE + OF
- + OPEN_PARENTHESIS
+ String method = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STATIC + SPACE + getCapitalCase(className) + SPACE
+ + OF + OPEN_PARENTHESIS
+ attrType + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE
+ EIGHT_SPACE_INDENTATION + SWITCH + SPACE + OPEN_PARENTHESIS + VALUE
+ CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
@@ -950,13 +950,13 @@
value = enumMap.get(str);
method = method + TWELVE_SPACE_INDENTATION + CASE + SPACE + value + COLAN + NEW_LINE
- + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + className + PERIOD
+ + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + getCapitalCase(className) + PERIOD
+ str + SEMI_COLAN + NEW_LINE;
}
method = method + TWELVE_SPACE_INDENTATION + DEFAULT + SPACE + COLAN + NEW_LINE + SIXTEEN_SPACE_INDENTATION
+ RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET
+ NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
- return getJavaDoc(OF_METHOD, className + " for type " + attrName, false) + method;
+ return getJavaDoc(OF_METHOD, getCapitalCase(className) + " for type " + attrName, false) + method;
}
}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java
index d285351..e92b963 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java
@@ -40,7 +40,7 @@
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeInfoInParentTempFile;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO;
@@ -69,9 +69,8 @@
YangPluginConfig yangPluginConfig)
throws IOException {
javaCodeGeneratorInfo.getJavaFileInfo()
- .setJavaName(getCaptialCase(
- getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(),
- yangPluginConfig.getConflictResolver())));
+ .setJavaName(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(),
+ yangPluginConfig.getConflictResolver()));
javaCodeGeneratorInfo.getJavaFileInfo().setPackage(getCurNodePackage((YangNode) javaCodeGeneratorInfo));
javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath(
getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage()));
@@ -89,8 +88,8 @@
String pkg)
throws IOException {
javaCodeGeneratorInfo.getJavaFileInfo()
- .setJavaName(getCaptialCase(
- getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(), yangPlugin.getConflictResolver())));
+ .setJavaName(getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(),
+ yangPlugin.getConflictResolver()));
javaCodeGeneratorInfo.getJavaFileInfo().setPackage(pkg);
javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath(
getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage()));
@@ -236,7 +235,7 @@
YangNode parent = ((YangCase) javaCodeGeneratorInfo).getParent();
String curNodeName = ((YangCase) javaCodeGeneratorInfo).getName();
if (!parent.getName().equals(curNodeName)) {
- javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().addToExtendsList(getCaptialCase(getCamelCase(
+ javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().addToExtendsList(getCapitalCase(getCamelCase(
parent.getName(), null)));
javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles().getBeanTempFiles()
.addParentInfoInCurNodeTempFile((YangNode) javaCodeGeneratorInfo);
diff --git a/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java b/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
index dc7920a..b28bc66 100644
--- a/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
+++ b/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
@@ -687,6 +687,11 @@
public static final String REGEX_FOR_FIRST_DIGIT = "\\d.*";
/**
+ * Static attribute for regex with digits.
+ */
+ public static final String REGEX_WITH_DIGITS = "(?=\\d+)";
+
+ /**
* Static attribute for regex for single letter.
*/
public static final String REGEX_FOR_SINGLE_LETTER = "[a-zA-Z]";
@@ -697,6 +702,21 @@
public static final String REGEX_FOR_DIGITS_WITH_SINGLE_LETTER = "[0-9]+[a-zA-Z]";
/**
+ * Static attribute for regex with uppercase.
+ */
+ public static final String REGEX_WITH_UPPERCASE = "(?=\\p{Upper})";
+
+ /**
+ * Static attribute for regex for single capital case letter.
+ */
+ public static final String REGEX_WITH_SINGLE_CAPITAL_CASE = "[A-Z]";
+
+ /**
+ * Static attribute for regex for capital case letter with any number of digits and small case letters.
+ */
+ public static final String REGEX_WITH_SINGLE_CAPITAL_CASE_AND_DIGITS_SMALL_CASES = "[A-Z][0-9a-z]+";
+
+ /**
* Static attribute for class syntax.
*/
public static final String CLASS = "class";
diff --git a/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java b/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
index cf92284..a3b9200 100644
--- a/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
+++ b/src/test/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntaxTest.java
@@ -25,7 +25,7 @@
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
-import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCapitalCase;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getJavaPackageFromPackagePath;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
@@ -61,6 +61,22 @@
private static final String WITH_CAMEL_CASE3 = "yangAutoPrefix1123G123Gaa";
private static final String WITHOUT_CAMEL_CASE4 = "a-b-c-d-e-f-g-h";
private static final String WITH_CAMEL_CASE4 = "aBcDeFgh";
+ private static final String WITHOUT_CAMEL_CASE5 = "TestName";
+ private static final String WITH_CAMEL_CASE5 = "testName";
+ private static final String WITHOUT_CAMEL_CASE6 = "TEST-NAME";
+ private static final String WITH_CAMEL_CASE6 = "testName";
+ private static final String WITHOUT_CAMEL_CASE7 = "TESTNAME";
+ private static final String WITH_CAMEL_CASE7 = "testname";
+ private static final String WITHOUT_CAMEL_CASE8 = "TE-ST-NA-ME";
+ private static final String WITH_CAMEL_CASE8 = "teStNaMe";
+ private static final String WITHOUT_CAMEL_CASE9 = "TEST3NAME";
+ private static final String WITH_CAMEL_CASE9 = "test3Name";
+ private static final String WITHOUT_CAMEL_CASE10 = "TEST3";
+ private static final String WITH_CAMEL_CASE10 = "test3";
+ private static final String WITHOUT_CAMEL_CASE11 = "TEST3nAMe";
+ private static final String WITH_CAMEL_CASE11 = "test3Name";
+ private static final String WITHOUT_CAMEL_CASE12 = "TEST3name";
+ private static final String WITH_CAMEL_CASE12 = "test3Name";
private static final String WITHOUT_CAPITAL = "test_this";
private static final String WITH_CAPITAL = "Test_this";
private static final String WITH_SMALL = "test_this";
@@ -129,7 +145,7 @@
*/
@Test
public void getCapitalCaseTest() {
- String capitalCase = getCaptialCase(WITHOUT_CAPITAL);
+ String capitalCase = getCapitalCase(WITHOUT_CAPITAL);
assertThat(capitalCase.equals(WITH_CAPITAL), is(true));
}
@@ -148,6 +164,22 @@
assertThat(camelCase3.equals(WITH_CAMEL_CASE3), is(true));
String camelCase4 = getCamelCase(WITHOUT_CAMEL_CASE4, null);
assertThat(camelCase4.equals(WITH_CAMEL_CASE4), is(true));
+ String camelCase5 = getCamelCase(WITHOUT_CAMEL_CASE5, null);
+ assertThat(camelCase5.equals(WITH_CAMEL_CASE5), is(true));
+ String camelCase6 = getCamelCase(WITHOUT_CAMEL_CASE6, null);
+ assertThat(camelCase6.equals(WITH_CAMEL_CASE6), is(true));
+ String camelCase7 = getCamelCase(WITHOUT_CAMEL_CASE7, null);
+ assertThat(camelCase7.equals(WITH_CAMEL_CASE7), is(true));
+ String camelCase8 = getCamelCase(WITHOUT_CAMEL_CASE8, null);
+ assertThat(camelCase8.equals(WITH_CAMEL_CASE8), is(true));
+ String camelCase9 = getCamelCase(WITHOUT_CAMEL_CASE9, null);
+ assertThat(camelCase9.equals(WITH_CAMEL_CASE9), is(true));
+ String camelCase10 = getCamelCase(WITHOUT_CAMEL_CASE10, null);
+ assertThat(camelCase10.equals(WITH_CAMEL_CASE10), is(true));
+ String camelCase11 = getCamelCase(WITHOUT_CAMEL_CASE11, null);
+ assertThat(camelCase11.equals(WITH_CAMEL_CASE11), is(true));
+ String camelCase12 = getCamelCase(WITHOUT_CAMEL_CASE12, null);
+ assertThat(camelCase12.equals(WITH_CAMEL_CASE12), is(true));
}
/**