[ONOS-5782]Builder pattern to be replaced with Setters for generated code
Change-Id: I84ce48d581e79f14d4003af1ff7ba248f04c48e5
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/GeneratedJavaFileType.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/GeneratedJavaFileType.java
index d0ac3b6..d48c4f9 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/GeneratedJavaFileType.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/GeneratedJavaFileType.java
@@ -27,16 +27,6 @@
public static final int INTERFACE_MASK = 1;
/**
- * Builder interface file.
- */
- public static final int BUILDER_INTERFACE_MASK = 2;
-
- /**
- * Builder class file.
- */
- public static final int BUILDER_CLASS_MASK = 4;
-
- /**
* Impl class file.
*/
public static final int DEFAULT_CLASS_MASK = 8;
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaCodeFragmentFiles.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaCodeFragmentFiles.java
index 766e70e..6a78c25 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaCodeFragmentFiles.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaCodeFragmentFiles.java
@@ -28,7 +28,6 @@
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS;
-import static org.onosproject.yang.compiler.utils.UtilConstants.BUILDER;
/**
* Represents implementation of java code fragments temporary implementations.
@@ -196,20 +195,6 @@
}
/**
- * Adds build method for interface.
- *
- * @return build method for interface
- * @throws IOException when fails to append to temporary file
- */
- public String addBuildMethodForInterface()
- throws IOException {
- if (beanTempFiles != null) {
- return beanTempFiles.addBuildMethodForInterface();
- }
- throw new TranslatorException("build method only supported for bean class");
- }
-
- /**
* Adds default constructor for class.
*
* @param modifier modifier for constructor.
@@ -220,9 +205,7 @@
public String addDefaultConstructor(String modifier, String toAppend)
throws IOException {
boolean isSuffix = false;
- if (toAppend.equals(BUILDER)) {
- isSuffix = true;
- }
+
if (typeTempFiles != null) {
return typeTempFiles.addDefaultConstructor(modifier, toAppend,
isSuffix);
@@ -236,20 +219,6 @@
}
/**
- * Adds build method's implementation for class.
- *
- * @return build method implementation for class
- * @throws IOException when fails to append to temporary file
- */
- public String addBuildMethodImpl()
- throws IOException {
- if (beanTempFiles != null) {
- return beanTempFiles.addBuildMethodImpl();
- }
- throw new TranslatorException("build should not be added");
- }
-
- /**
* Removes all temporary file handles.
* when translator fails to generate java files we need to close
* all open file handles include temporary files and java files
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaFragmentFiles.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaFragmentFiles.java
index 426806a..b88ce13 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaFragmentFiles.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaFragmentFiles.java
@@ -44,10 +44,9 @@
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.BITS;
import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.IDENTITYREF;
-import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
-import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_TYPE_CLASS;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
@@ -71,8 +70,6 @@
import static org.onosproject.yang.compiler.translator.tojava.javamodel.AttributesJavaDataType.updateJavaFileInfo;
import static org.onosproject.yang.compiler.translator.tojava.utils.JavaCodeSnippetGen.generateEnumAttributeString;
import static org.onosproject.yang.compiler.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefinition;
-import static org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile;
-import static org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile;
import static org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGenerator.generateDefaultClassFile;
import static org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile;
import static org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGenerator.generateKeyClassFile;
@@ -80,7 +77,6 @@
import static org.onosproject.yang.compiler.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getAddToListMethodImpl;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getAddToListMethodInterface;
-import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getBuildString;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getEqualsMethod;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getFromStringMethod;
@@ -91,7 +87,6 @@
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getSetterString;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getToStringMethod;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getYangDataStructure;
-import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString;
import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.getImportString;
import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.getOverRideString;
import static org.onosproject.yang.compiler.translator.tojava.utils.TranslatorErrorType.INVALID_LEAF_HOLDER;
@@ -101,7 +96,6 @@
import static org.onosproject.yang.compiler.translator.tojava.utils.TranslatorUtils.getBeanFiles;
import static org.onosproject.yang.compiler.translator.tojava.utils.TranslatorUtils.getErrorMsg;
import static org.onosproject.yang.compiler.utils.UtilConstants.BIT_SET;
-import static org.onosproject.yang.compiler.utils.UtilConstants.BUILDER;
import static org.onosproject.yang.compiler.utils.UtilConstants.CLASS_STRING;
import static org.onosproject.yang.compiler.utils.UtilConstants.CLOSE_CURLY_BRACKET;
import static org.onosproject.yang.compiler.utils.UtilConstants.DEFAULT;
@@ -113,7 +107,6 @@
import static org.onosproject.yang.compiler.utils.UtilConstants.FOUR_SPACE_INDENTATION;
import static org.onosproject.yang.compiler.utils.UtilConstants.GOOGLE_MORE_OBJECT_IMPORT_CLASS;
import static org.onosproject.yang.compiler.utils.UtilConstants.GOOGLE_MORE_OBJECT_IMPORT_PKG;
-import static org.onosproject.yang.compiler.utils.UtilConstants.INTERFACE;
import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_CLASS;
import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_UTIL_PKG;
import static org.onosproject.yang.compiler.utils.UtilConstants.KEYS;
@@ -134,13 +127,13 @@
import static org.onosproject.yang.compiler.utils.io.impl.FileSystemUtil.readAppendFile;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.ADD_TO_LIST;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
+import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.getJavaDoc;
import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getCamelCase;
import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getCapitalCase;
import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getPackageDirPathFromJavaJPackage;
import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
-import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.mergeJavaFiles;
import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.validateLineLength;
/**
@@ -257,16 +250,6 @@
*/
private static final String INTERFACE_FILE_NAME_SUFFIX = EMPTY_STRING;
- /**
- * File name for builder interface file name suffix.
- */
- private static final String BUILDER_INTERFACE_FILE_NAME_SUFFIX =
- BUILDER + INTERFACE;
-
- /**
- * File name for builder class file name suffix.
- */
- private static final String BUILDER_CLASS_FILE_NAME_SUFFIX = BUILDER;
/**
* File name for list key class file name suffix.
@@ -311,16 +294,6 @@
private File interfaceJavaFileHandle;
/**
- * Java file handle for builder interface file.
- */
- private File builderInterfaceJavaFileHandle;
-
- /**
- * Java file handle for builder class file.
- */
- private File builderClassJavaFileHandle;
-
- /**
* Java file handle for impl class file.
*/
private File implClassJavaFileHandle;
@@ -434,22 +407,7 @@
ADD_TO_LIST_INTERFACE_MASK |
LEAF_IDENTIFIER_ENUM_ATTRIBUTES_MASK);
}
- /*
- * Initialize getter and setter when generation file type matches to
- * builder interface mask.
- */
- if (javaFlagSet(BUILDER_INTERFACE_MASK)) {
- addGeneratedTempFile(GETTER_FOR_INTERFACE_MASK |
- SETTER_FOR_INTERFACE_MASK);
- }
- /*
- * Initialize getterImpl, setterImpl and attributes when generation file
- * type matches to builder class mask.
- */
- if (javaFlagSet(BUILDER_CLASS_MASK)) {
- addGeneratedTempFile(ATTRIBUTES_MASK | GETTER_FOR_CLASS_MASK |
- SETTER_FOR_CLASS_MASK);
- }
+
/*
* Initialize getterImpl, attributes, constructor, hash code, equals and
* to strings when generation file type matches to impl class mask.
@@ -457,6 +415,7 @@
if (javaFlagSet(DEFAULT_CLASS_MASK)) {
addGeneratedTempFile(
ATTRIBUTES_MASK | GETTER_FOR_CLASS_MASK |
+ SETTER_FOR_CLASS_MASK |
HASH_CODE_IMPL_MASK | EQUALS_IMPL_MASK |
TO_STRING_IMPL_MASK | ADD_TO_LIST_IMPL_MASK);
}
@@ -465,6 +424,7 @@
*/
if (javaFlagSet(GENERATE_TYPE_CLASS)) {
addGeneratedTempFile(ATTRIBUTES_MASK | GETTER_FOR_CLASS_MASK |
+ SETTER_FOR_CLASS_MASK |
HASH_CODE_IMPL_MASK | EQUALS_IMPL_MASK |
FROM_STRING_IMPL_MASK);
@@ -1037,10 +997,25 @@
*/
private void addSetterImpl(JavaAttributeInfo attr)
throws IOException {
+ int generatedJavaFiles = getGeneratedJavaFiles();
String setter = getSetterForClass(attr, getGeneratedJavaClassName(),
- getGeneratedJavaFiles());
- String javadoc = getOverRideString();
- appendToFile(setterImplTempFileHandle, javadoc + setter);
+ generatedJavaFiles);
+ YangDataStructure ds = getYangDataStructure(
+ attr.getCompilerAnnotation());
+ String annotation = null;
+ if (ds != null) {
+ annotation = ds.name();
+ }
+ String javaDoc;
+ if (generatedJavaFiles != GENERATE_TYPEDEF_CLASS &&
+ generatedJavaFiles != GENERATE_UNION_CLASS) {
+ javaDoc = getOverRideString();
+ } else {
+ javaDoc = getJavaDoc(SETTER_METHOD, attr.getAttributeName(),
+ false, annotation);
+ }
+ appendToFile(setterImplTempFileHandle,
+ javaDoc + setter);
}
/**
@@ -1051,21 +1026,23 @@
*/
protected void addGetterImpl(JavaAttributeInfo attr)
throws IOException {
+ int generatedJavaFiles = getGeneratedJavaFiles();
String getter = getGetterForClass(attr, getGeneratedJavaFiles());
- String javadoc = getOverRideString();
YangDataStructure ds = getYangDataStructure(
attr.getCompilerAnnotation());
String annotation = null;
if (ds != null) {
annotation = ds.name();
}
- if (javaFlagSet(BUILDER_CLASS_MASK)) {
- appendToFile(getterImplTempFileHandle, javadoc + getter);
+ String javaDoc;
+ if (generatedJavaFiles != GENERATE_TYPEDEF_CLASS &&
+ generatedJavaFiles != GENERATE_UNION_CLASS) {
+ javaDoc = getOverRideString();
} else {
- appendToFile(getterImplTempFileHandle,
- getJavaDoc(GETTER_METHOD, attr.getAttributeName(),
- false, annotation) + getter);
+ javaDoc = getJavaDoc(GETTER_METHOD, attr.getAttributeName(),
+ false, annotation);
}
+ appendToFile(getterImplTempFileHandle, javaDoc + getter);
}
/**
@@ -1115,29 +1092,6 @@
}
/**
- * Adds build method for interface.
- *
- * @return build method for interface
- * @throws IOException when fails to append to temporary file
- */
- protected String addBuildMethodForInterface()
- throws IOException {
- return parseBuilderInterfaceBuildMethodString(
- getGeneratedJavaClassName());
- }
-
- /**
- * Adds build method's implementation for class.
- *
- * @return build method implementation for class
- * @throws IOException when fails to append to temporary file
- */
- protected String addBuildMethodImpl()
- throws IOException {
- return getBuildString(getGeneratedJavaClassName(), rootNode) + NEW_LINE;
- }
-
- /**
* Adds default constructor for class.
*
* @param modifier modifier for constructor
@@ -1151,7 +1105,7 @@
throws IOException {
StringBuilder name = new StringBuilder();
name.append(getGeneratedJavaClassName());
- if (rootNode && !toAppend.equals(BUILDER)) {
+ if (rootNode) {
name.append(OP_PARAM);
return getDefaultConstructorString(name.toString(), modifier);
}
@@ -1632,8 +1586,7 @@
createPackage(curNode);
//Generate java code.
- if ((fileType & INTERFACE_MASK) != 0 ||
- (fileType & BUILDER_INTERFACE_MASK) != 0) {
+ if ((fileType & INTERFACE_MASK) != 0) {
//Create interface file.
interfaceJavaFileHandle =
@@ -1642,23 +1595,6 @@
generateInterfaceFile(interfaceJavaFileHandle, imports,
curNode, isAttributePresent);
- //Create builder interface file.
- if ((fileType & BUILDER_INTERFACE_MASK) != 0) {
- builderInterfaceJavaFileHandle =
- getJavaFileHandle(getJavaClassName(
- BUILDER_INTERFACE_FILE_NAME_SUFFIX));
- builderInterfaceJavaFileHandle =
- generateBuilderInterfaceFile(
- builderInterfaceJavaFileHandle,
- curNode, isAttributePresent);
- /*
- * Append builder interface file to interface file and
- * close it.
- */
- mergeJavaFiles(builderInterfaceJavaFileHandle,
- interfaceJavaFileHandle);
- }
-
insertDataIntoJavaFile(interfaceJavaFileHandle, CLOSE_CURLY_BRACKET);
validateLineLength(interfaceJavaFileHandle);
}
@@ -1670,6 +1606,7 @@
}
if ((fileType & DEFAULT_CLASS_MASK) != 0) {
+
//add model object to extend list
JavaQualifiedTypeInfoTranslator typeInfo = new
JavaQualifiedTypeInfoTranslator();
@@ -1679,10 +1616,6 @@
typeInfo.setQualified(false);
getBeanFiles(curNode).getJavaExtendsListHolder()
.addToExtendsList(typeInfo, curNode, getBeanFiles(curNode));
- }
-
- if ((fileType & BUILDER_CLASS_MASK) != 0 ||
- (fileType & DEFAULT_CLASS_MASK) != 0) {
//Create impl class file.
implClassJavaFileHandle =
@@ -1692,21 +1625,6 @@
curNode, isAttributePresent,
imports);
- //Create builder class file.
- if ((fileType & BUILDER_CLASS_MASK) != 0) {
- builderClassJavaFileHandle =
- getJavaFileHandle(getJavaClassName(
- BUILDER_CLASS_FILE_NAME_SUFFIX));
- builderClassJavaFileHandle =
- generateBuilderClassFile(builderClassJavaFileHandle,
- curNode,
- isAttributePresent);
-
- //Append impl class to builder class and close it.
- mergeJavaFiles(builderClassJavaFileHandle,
- implClassJavaFileHandle);
- }
-
insertDataIntoJavaFile(implClassJavaFileHandle, CLOSE_CURLY_BRACKET);
validateLineLength(implClassJavaFileHandle);
}
@@ -1751,12 +1669,7 @@
if (javaFlagSet(INTERFACE_MASK)) {
closeFile(interfaceJavaFileHandle, errorOccurred);
}
- if (javaFlagSet(BUILDER_CLASS_MASK)) {
- closeFile(builderClassJavaFileHandle);
- }
- if (javaFlagSet(BUILDER_INTERFACE_MASK)) {
- closeFile(builderInterfaceJavaFileHandle);
- }
+
if (javaFlagSet(DEFAULT_CLASS_MASK)) {
closeFile(implClassJavaFileHandle, errorOccurred);
}
@@ -1766,6 +1679,9 @@
if (tempFlagSet(GETTER_FOR_CLASS_MASK)) {
closeFile(getterImplTempFileHandle);
}
+ if (tempFlagSet(SETTER_FOR_CLASS_MASK)) {
+ closeFile(setterImplTempFileHandle);
+ }
if (tempFlagSet(ATTRIBUTES_MASK)) {
closeFile(attributesTempFileHandle);
}
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/ClassDefinitionGenerator.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/ClassDefinitionGenerator.java
index 896426a..db01b11 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/ClassDefinitionGenerator.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/ClassDefinitionGenerator.java
@@ -17,7 +17,6 @@
package org.onosproject.yang.compiler.translator.tojava.utils;
import org.onosproject.yang.compiler.datamodel.RpcNotificationContainer;
-import org.onosproject.yang.compiler.datamodel.YangAugment;
import org.onosproject.yang.compiler.datamodel.YangCase;
import org.onosproject.yang.compiler.datamodel.YangIdentity;
import org.onosproject.yang.compiler.datamodel.YangNode;
@@ -28,8 +27,6 @@
import org.onosproject.yang.compiler.translator.tojava.JavaQualifiedTypeInfoTranslator;
import org.onosproject.yang.compiler.translator.tojava.TempJavaCodeFragmentFilesContainer;
-import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
-import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS;
@@ -43,7 +40,6 @@
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
import static org.onosproject.yang.compiler.translator.tojava.utils.BracketType.OPEN_CLOSE_DIAMOND_WITH_VALUE;
import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.brackets;
-import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.getBuilderImplStringClassDef;
import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.getDefaultDefinition;
import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.getDefaultDefinitionWithExtends;
import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.getDefaultDefinitionWithImpl;
@@ -55,7 +51,6 @@
import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.getSuffixedName;
import static org.onosproject.yang.compiler.utils.UtilConstants.ABSTRACT;
import static org.onosproject.yang.compiler.utils.UtilConstants.ABSTRACT_EVENT;
-import static org.onosproject.yang.compiler.utils.UtilConstants.BUILDER;
import static org.onosproject.yang.compiler.utils.UtilConstants.CLASS;
import static org.onosproject.yang.compiler.utils.UtilConstants.COMMA;
import static org.onosproject.yang.compiler.utils.UtilConstants.COMPARABLE;
@@ -80,7 +75,6 @@
import static org.onosproject.yang.compiler.utils.UtilConstants.REGEX_FOR_ANY_STRING_ENDING_WITH_SERVICE;
import static org.onosproject.yang.compiler.utils.UtilConstants.SERVICE;
import static org.onosproject.yang.compiler.utils.UtilConstants.SPACE;
-import static org.onosproject.yang.compiler.utils.UtilConstants.STATIC;
import static org.onosproject.yang.compiler.utils.UtilConstants.SUBJECT;
import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getCapitalCase;
import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.trimAtLast;
@@ -139,12 +133,8 @@
switch (genFileTypes) {
case INTERFACE_MASK:
return getInterfaceDefinition(yangName, curNode);
- case BUILDER_CLASS_MASK:
- return getBuilderClassDefinition(yangName, curNode);
case DEFAULT_CLASS_MASK:
return getImplClassDefinition(yangName, curNode);
- case BUILDER_INTERFACE_MASK:
- return getBuilderInterfaceDefinition(yangName, curNode);
case GENERATE_SERVICE_AND_MANAGER:
return getRpcInterfaceDefinition(yangName, curNode);
case GENERATE_EVENT_CLASS:
@@ -191,48 +181,6 @@
}
/**
- * Returns builder interface file class definition.
- *
- * @param yangName java class name, corresponding to which the builder
- * class is being generated
- * @return definition
- */
- private static String getBuilderInterfaceDefinition(String yangName,
- YangNode curNode) {
- if (!(curNode instanceof YangCase) &&
- !(curNode instanceof YangAugment)) {
- String clsDef = getClassDefinitionForWhenExtended(
- curNode, yangName, BUILDER_INTERFACE_MASK);
- if (clsDef != null) {
- return clsDef;
- }
- }
- return getDefaultDefinition(INTERFACE, getSuffixedName(yangName, BUILDER),
- null);
- }
-
- /**
- * Returns builder file class definition.
- *
- * @param yangName file name
- * @return definition
- */
- private static String getBuilderClassDefinition(String yangName,
- YangNode curNode) {
- String mod = getSpecificModifier(PUBLIC, STATIC);
- String bName = getSuffixedName(yangName, BUILDER);
- if (!(curNode instanceof YangCase)) {
- String clsDef = getClassDefinitionForWhenExtended(curNode, yangName,
- BUILDER_CLASS_MASK);
- if (clsDef != null) {
- return clsDef;
- }
- }
- return getDefaultDefinitionWithImpl(CLASS, bName, mod,
- getBuilderImplStringClassDef(yangName));
- }
-
- /**
* Returns impl file class definition.
*
* @param yangName file name
@@ -403,31 +351,6 @@
def = new StringBuilder(getDefinitionString(def.toString(),
holder));
break;
- case BUILDER_INTERFACE_MASK:
- def.append(INTERFACE)
- .append(SPACE).append(yangName).append(BUILDER)
- .append(SPACE).append(EXTEND).append(SPACE);
- def = new StringBuilder(getDefinitionString(
- def.toString(), holder));
- break;
- case BUILDER_CLASS_MASK:
- boolean isModelObject = false;
- for (JavaQualifiedTypeInfoTranslator info : holder.getExtendsList()) {
- if (info.getClassInfo().equals(MODEL_OBJECT)) {
- isModelObject = true;
- }
- }
- def.append(STATIC).append(SPACE).append(CLASS)
- .append(SPACE).append(yangName).append(BUILDER);
- if (!isModelObject) {
- def.append(SPACE).append(EXTEND).append(SPACE);
- def = new StringBuilder(getDefinitionString(def.toString(),
- holder));
- }
- def.append(SPACE).append(IMPLEMENTS).append(SPACE)
- .append(yangName).append(PERIOD)
- .append(yangName).append(BUILDER);
- break;
case DEFAULT_CLASS_MASK:
// class defination
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGenerator.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGenerator.java
index b9c609e..e886af2 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGenerator.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGenerator.java
@@ -42,8 +42,6 @@
import java.util.List;
import static java.util.Collections.sort;
-import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
-import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS;
@@ -54,11 +52,8 @@
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
-import static org.onosproject.yang.compiler.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_IMPL_MASK;
-import static org.onosproject.yang.compiler.translator.tojava.GeneratedTempFileType.ADD_TO_LIST_INTERFACE_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK;
-import static org.onosproject.yang.compiler.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedTempFileType.EVENT_ENUM_MASK;
@@ -89,14 +84,12 @@
import static org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodBodyTypes.ENUM_METHOD_INT_VALUE;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodBodyTypes.ENUM_METHOD_STRING_VALUE;
-import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.builderMethod;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getAddAugmentationString;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getAugmentationString;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getAugmentationsString;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getBitSetEnumClassFromString;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getBitSetEnumClassToString;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getCompareToForKeyClass;
-import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getConstructorStart;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getEnumsConstructor;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getEnumsOfValueMethod;
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getEqualsMethod;
@@ -128,9 +121,6 @@
import static org.onosproject.yang.compiler.translator.tojava.utils.TranslatorUtils.getBeanFiles;
import static org.onosproject.yang.compiler.translator.tojava.utils.TranslatorUtils.getTypeFiles;
import static org.onosproject.yang.compiler.utils.UtilConstants.BIG_INTEGER;
-import static org.onosproject.yang.compiler.utils.UtilConstants.BUILDER;
-import static org.onosproject.yang.compiler.utils.UtilConstants.BUILDER_CLASS;
-import static org.onosproject.yang.compiler.utils.UtilConstants.BUILDER_INTERFACE;
import static org.onosproject.yang.compiler.utils.UtilConstants.CLOSE_CURLY_BRACKET;
import static org.onosproject.yang.compiler.utils.UtilConstants.COMMA;
import static org.onosproject.yang.compiler.utils.UtilConstants.DEFAULT;
@@ -237,6 +227,9 @@
//Getter methods.
insertDataIntoJavaFile(file, getDataFromTempFileHandle(
GETTER_FOR_INTERFACE_MASK, getBeanFiles(curNode), path));
+
+ insertDataIntoJavaFile(file, getDataFromTempFileHandle(
+ SETTER_FOR_INTERFACE_MASK, getBeanFiles(curNode), path));
} catch (IOException e) {
throw new IOException(getErrorMsg(className, INTERFACE));
}
@@ -252,161 +245,6 @@
}
/**
- * Returns generated builder interface file for current node.
- *
- * @param file file
- * @param curNode current YANG node
- * @param attrPresent if any attribute is present or not
- * @return builder interface file
- * @throws IOException when fails to write in file
- */
- public static File generateBuilderInterfaceFile(File file, YangNode curNode,
- boolean attrPresent)
- throws IOException {
-
- JavaFileInfoTranslator fileInfo =
- ((JavaFileInfoContainer) curNode).getJavaFileInfo();
-
- boolean leavesPresent;
- YangLeavesHolder leavesHolder;
- if (curNode instanceof YangLeavesHolder &&
- curNode.isOpTypeReq()) {
- leavesHolder = (YangLeavesHolder) curNode;
- leavesPresent = leavesPresent(leavesHolder);
- } else {
- leavesPresent = false;
- }
-
- String className = getCapitalCase(fileInfo.getJavaName());
- String path;
- if (curNode instanceof RpcNotificationContainer) {
- path = fileInfo.getPluginConfig().getCodeGenDir() +
- fileInfo.getPackageFilePath();
- } else {
- path = fileInfo.getBaseCodeGenPath() +
- fileInfo.getPackageFilePath();
- }
-
- initiateJavaFileGeneration(file, BUILDER_INTERFACE_MASK, null, curNode,
- className);
- List<String> methods = new ArrayList<>();
- if (attrPresent) {
- try {
- //Getter methods.
- methods.add(getDataFromTempFileHandle(
- GETTER_FOR_INTERFACE_MASK,
- getBeanFiles(curNode), path));
-
- //Setter methods.
- methods.add(getDataFromTempFileHandle(
- SETTER_FOR_INTERFACE_MASK,
- getBeanFiles(curNode), path));
-
- //Add to list method.
- insertDataIntoJavaFile(file, getDataFromTempFileHandle(
- ADD_TO_LIST_INTERFACE_MASK, getBeanFiles(curNode), path));
- } catch (IOException e) {
- throw new IOException(getErrorMsg(className, BUILDER_INTERFACE));
- }
- }
-
- //Add build method to builder interface file.
- methods.add(((TempJavaCodeFragmentFilesContainer) curNode)
- .getTempJavaCodeFragmentFiles()
- .addBuildMethodForInterface());
-
- //Add getters and setters in builder interface.
- for (String method : methods) {
- insertDataIntoJavaFile(file, method);
- }
-
- insertDataIntoJavaFile(file, CLOSE_CURLY_BRACKET + NEW_LINE);
- return file;
- }
-
- /**
- * Returns generated builder class file for current node.
- *
- * @param file file
- * @param curNode current YANG node
- * @param attrPresent if any attribute is present or not
- * @return builder class file
- * @throws IOException when fails to write in file
- */
- public static File generateBuilderClassFile(File file, YangNode curNode,
- boolean attrPresent)
- throws IOException {
-
- JavaFileInfoTranslator fileInfo =
- ((JavaFileInfoContainer) curNode).getJavaFileInfo();
-
- boolean leavesPresent;
- YangLeavesHolder leavesHolder;
- if (curNode instanceof YangLeavesHolder) {
- leavesHolder = (YangLeavesHolder) curNode;
- leavesPresent = leavesPresent(leavesHolder);
- } else {
- leavesPresent = false;
- }
-
- String className = getCapitalCase(fileInfo.getJavaName());
- String path;
- if (curNode instanceof RpcNotificationContainer) {
- path = fileInfo.getPluginConfig().getCodeGenDir() +
- fileInfo.getPackageFilePath();
- } else {
- path = fileInfo.getBaseCodeGenPath() +
- fileInfo.getPackageFilePath();
- }
-
- initiateJavaFileGeneration(file, BUILDER_CLASS_MASK, null, curNode,
- className);
- List<String> methods = new ArrayList<>();
- if (attrPresent) {
-
- //Add attribute strings.
- try {
- insertDataIntoJavaFile(file, getDataFromTempFileHandle(
- ATTRIBUTES_MASK, getBeanFiles(curNode), path));
- } catch (IOException e) {
- throw new IOException(getErrorMsg(className, BUILDER_CLASS));
- }
- try {
- //Getter methods.
- methods.add(getDataFromTempFileHandle(
- GETTER_FOR_CLASS_MASK, getBeanFiles(curNode), path));
- // Setter methods.
- methods.add(getDataFromTempFileHandle(
- SETTER_FOR_CLASS_MASK, getBeanFiles(curNode), path));
-
- //Add to list impl method.
- methods.add(getDataFromTempFileHandle(
- ADD_TO_LIST_IMPL_MASK, getBeanFiles(curNode), path));
-
- insertDataIntoJavaFile(file, NEW_LINE);
- } catch (IOException e) {
- throw new IOException(getErrorMsg(className, BUILDER_CLASS));
- }
- } else {
- insertDataIntoJavaFile(file, NEW_LINE);
- }
-
- // Add default constructor and build method impl.
- methods.add(((TempJavaCodeFragmentFilesContainer) curNode)
- .getTempJavaCodeFragmentFiles()
- .addBuildMethodImpl());
-
- methods.add(addDefaultConstructor(curNode, PUBLIC, BUILDER));
-
- //Add methods in builder class.
- for (String method : methods) {
- insertDataIntoJavaFile(file, method);
- }
- insertDataIntoJavaFile(file, CLOSE_CURLY_BRACKET);
- return file;
- }
-
- /**
* Returns generated key class file for current list node.
*
* @param file file
@@ -557,20 +395,8 @@
insertDataIntoJavaFile(file, NEW_LINE);
}
- try {
- //Constructor.
- String constructor = getConstructorStart(className, rootNode) +
- getDataFromTempFileHandle(
- CONSTRUCTOR_IMPL_MASK, getBeanFiles(curNode), path)
- + methodClose(FOUR_SPACE);
- methods.add(constructor);
- } catch (IOException e) {
- throw new IOException(getErrorMsg(className, IMPL_CLASS));
- }
+ methods.add(addDefaultConstructor(curNode, PUBLIC, DEFAULT));
- methods.add(addDefaultConstructor(curNode, PROTECTED, DEFAULT));
-
- methods.add(builderMethod(className));
if (leavesPresent) {
methods.add(getIsValueLeafSet());
}
@@ -622,6 +448,10 @@
methods.add(getDataFromTempFileHandle(
GETTER_FOR_CLASS_MASK, getBeanFiles(curNode), path));
+ //Getter methods.
+ methods.add(getDataFromTempFileHandle(
+ SETTER_FOR_CLASS_MASK, getBeanFiles(curNode), path));
+
// Hash code method.
methods.add(getHashCodeMethodClose(
getHashCodeMethodOpen() + getDataFromTempFileHandle(
@@ -700,6 +530,10 @@
methods.add(getDataFromTempFileHandle(
GETTER_FOR_CLASS_MASK, getTypeFiles(curNode), path));
+ //Setter methods.
+ methods.add(getDataFromTempFileHandle(
+ SETTER_FOR_CLASS_MASK, getTypeFiles(curNode), path));
+
// Hash code method.
methods.add(getHashCodeMethodClose(
getHashCodeMethodOpen() + getDataFromTempFileHandle(
@@ -843,6 +677,10 @@
methods.add(getDataFromTempFileHandle(
GETTER_FOR_CLASS_MASK, getTypeFiles(curNode), path));
+ //Setter methods.
+ methods.add(getDataFromTempFileHandle(
+ SETTER_FOR_CLASS_MASK, getTypeFiles(curNode), path));
+
//Hash code method.
methods.add(getHashCodeMethodClose(
getHashCodeMethodOpen() +
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGeneratorUtils.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGeneratorUtils.java
index 6c1ac6b..6668e2d 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGeneratorUtils.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGeneratorUtils.java
@@ -45,8 +45,6 @@
import java.util.ArrayList;
import java.util.List;
-import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
-import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.DEFAULT_CLASS_MASK;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_CLASS;
@@ -96,8 +94,6 @@
import static org.onosproject.yang.compiler.utils.UtilConstants.SLASH;
import static org.onosproject.yang.compiler.utils.UtilConstants.SPACE;
import static org.onosproject.yang.compiler.utils.io.impl.CopyrightHeader.parseCopyrightHeader;
-import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_CLASS;
-import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_INTERFACE;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CLASS;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.ENUM_CLASS;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.EVENT;
@@ -444,12 +440,6 @@
write(file, genType, DEFAULT_CLASS, curNode, className,
curNode.isOpTypeReq());
break;
- case BUILDER_CLASS_MASK:
- write(file, genType, BUILDER_CLASS, curNode, className, false);
- break;
- case BUILDER_INTERFACE_MASK:
- write(file, genType, BUILDER_INTERFACE, curNode, className, false);
- break;
case GENERATE_SERVICE_AND_MANAGER:
appendHeaderContents(file, pkgString, importsList);
write(file, genType, RPC_INTERFACE, curNode, className, false);
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodBodyTypes.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodBodyTypes.java
index 2622809..6bcb896 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodBodyTypes.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodBodyTypes.java
@@ -27,9 +27,6 @@
//Setter method body.
SETTER,
- //Build method body.
- BUILD,
-
//Constructor method body.
CONSTRUCTOR,
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGenerator.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGenerator.java
index e25971f..9c14997 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGenerator.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGenerator.java
@@ -42,6 +42,7 @@
import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.IDENTITYREF;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_EVENT_SUBJECT_CLASS;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER;
+import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
import static org.onosproject.yang.compiler.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
import static org.onosproject.yang.compiler.translator.tojava.utils.BracketType.OPEN_CLOSE_BRACKET;
import static org.onosproject.yang.compiler.translator.tojava.utils.IndentationType.EIGHT_SPACE;
@@ -106,9 +107,6 @@
import static org.onosproject.yang.compiler.utils.UtilConstants.BITS;
import static org.onosproject.yang.compiler.utils.UtilConstants.BIT_SET;
import static org.onosproject.yang.compiler.utils.UtilConstants.BOOLEAN_DATA_TYPE;
-import static org.onosproject.yang.compiler.utils.UtilConstants.BUILD;
-import static org.onosproject.yang.compiler.utils.UtilConstants.BUILDER;
-import static org.onosproject.yang.compiler.utils.UtilConstants.BUILDER_LOWER_CASE;
import static org.onosproject.yang.compiler.utils.UtilConstants.CAMEL_CLASS;
import static org.onosproject.yang.compiler.utils.UtilConstants.CASE;
import static org.onosproject.yang.compiler.utils.UtilConstants.CLASS;
@@ -120,7 +118,6 @@
import static org.onosproject.yang.compiler.utils.UtilConstants.COMPARE_TO;
import static org.onosproject.yang.compiler.utils.UtilConstants.DECODE;
import static org.onosproject.yang.compiler.utils.UtilConstants.DEFAULT;
-import static org.onosproject.yang.compiler.utils.UtilConstants.DEFAULT_CAPS;
import static org.onosproject.yang.compiler.utils.UtilConstants.DIAMOND_CLOSE_BRACKET;
import static org.onosproject.yang.compiler.utils.UtilConstants.DIAMOND_OPEN_BRACKET;
import static org.onosproject.yang.compiler.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
@@ -165,7 +162,6 @@
import static org.onosproject.yang.compiler.utils.UtilConstants.NOT;
import static org.onosproject.yang.compiler.utils.UtilConstants.NULL;
import static org.onosproject.yang.compiler.utils.UtilConstants.OBJ;
-import static org.onosproject.yang.compiler.utils.UtilConstants.OBJECT;
import static org.onosproject.yang.compiler.utils.UtilConstants.OBJECT_STRING;
import static org.onosproject.yang.compiler.utils.UtilConstants.OF;
import static org.onosproject.yang.compiler.utils.UtilConstants.OF_CAPS;
@@ -176,11 +172,9 @@
import static org.onosproject.yang.compiler.utils.UtilConstants.OPERATION_TYPE_ATTRIBUTE;
import static org.onosproject.yang.compiler.utils.UtilConstants.OP_PARAM;
import static org.onosproject.yang.compiler.utils.UtilConstants.OTHER;
-import static org.onosproject.yang.compiler.utils.UtilConstants.OVERRIDE;
import static org.onosproject.yang.compiler.utils.UtilConstants.PERIOD;
import static org.onosproject.yang.compiler.utils.UtilConstants.PRIORITY_QUEUE;
import static org.onosproject.yang.compiler.utils.UtilConstants.PRIVATE;
-import static org.onosproject.yang.compiler.utils.UtilConstants.PROTECTED;
import static org.onosproject.yang.compiler.utils.UtilConstants.PUBLIC;
import static org.onosproject.yang.compiler.utils.UtilConstants.PUT;
import static org.onosproject.yang.compiler.utils.UtilConstants.QUESTION_MARK;
@@ -218,7 +212,6 @@
import static org.onosproject.yang.compiler.utils.UtilConstants.VARIABLE_C;
import static org.onosproject.yang.compiler.utils.UtilConstants.VOID;
import static org.onosproject.yang.compiler.utils.UtilConstants.ZERO;
-import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.FROM_METHOD;
@@ -227,7 +220,6 @@
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR;
-import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.generateForBuilderMethod;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.generateForGetMethodWithAttribute;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.generateForValidatorMethod;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.getJavaDoc;
@@ -250,17 +242,6 @@
}
/**
- * Returns the methods strings for builder interface.
- *
- * @param name attribute name
- * @return method string for builder interface
- */
- public static String parseBuilderInterfaceBuildMethodString(String name) {
- return getJavaDoc(BUILD_METHOD, name, false, null) +
- getBuildForInterface(name);
- }
-
- /**
* Returns getter string.
*
* @param attr attribute info
@@ -357,18 +338,6 @@
}
/**
- * Returns build method string.
- *
- * @param name class name
- * @param isRoot true if root node
- * @return build string
- */
- public static String getBuildString(String name, boolean isRoot) {
- return FOUR_SPACE_INDENTATION + OVERRIDE + NEW_LINE +
- getBuild(name, isRoot);
- }
-
- /**
* Returns add augmentation method string.
*
* @return add augmentation string
@@ -532,10 +501,12 @@
.append(methodClose(FOUR_SPACE));
return builder.toString();
}
- builder.append(methodSignature(name, EMPTY_STRING,
- PUBLIC, name, getCapitalCase(className) +
- BUILDER, type, CLASS_TYPE));
- if (!isTypeNull && !isList) {
+ //Append method signature.
+ builder.append(methodSignature(name, EMPTY_STRING, PUBLIC, name,
+ VOID, type, CLASS_TYPE));
+
+ if (!isTypeNull && !isList &&
+ genType != GENERATE_TYPEDEF_CLASS && genType != GENERATE_UNION_CLASS) {
builder.append(getLeafFlagSetString(name, VALUE_LEAF, EIGHT_SPACE_INDENTATION,
SET_METHOD_PREFIX)).append(signatureClose());
} else {
@@ -544,7 +515,7 @@
//Append method body.
builder.append(methodBody(SETTER, name, name,
EIGHT_SPACE_INDENTATION, null, null,
- true, null))
+ false, null))
//Append method close.
.append(methodClose(FOUR_SPACE));
return builder.toString();
@@ -655,13 +626,12 @@
String attrType,
int genType) {
if (genType == GENERATE_SERVICE_AND_MANAGER) {
- return methodSignature(getCapitalCase(attrName),
- SET_METHOD_PREFIX,
- null, attrName, VOID, attrType +
- OP_PARAM, INTERFACE_TYPE);
+ return methodSignature(getCapitalCase(attrName), SET_METHOD_PREFIX,
+ null, attrName, VOID, attrType + OP_PARAM,
+ INTERFACE_TYPE);
}
return methodSignature(attrName, EMPTY_STRING, null,
- attrName, name + BUILDER, attrType, INTERFACE_TYPE);
+ attrName, VOID, attrType, INTERFACE_TYPE);
}
/**
@@ -689,40 +659,6 @@
}
/**
- * Returns the build method strings for interface file.
- *
- * @param yangName name of the interface
- * @return build method for interface
- */
- static String getBuildForInterface(String yangName) {
- return methodSignature(BUILD, EMPTY_STRING, null, null,
- yangName, null, INTERFACE_TYPE);
- }
-
- /**
- * Returns constructor string for impl class.
- *
- * @param yangName class name
- * @param isRootNode if root node
- * @return constructor string
- */
- static String getConstructorStart(String yangName,
- boolean isRootNode) {
- StringBuilder builder = new StringBuilder(
- getConstructorString(yangName));
-
- String name = getCapitalCase(yangName);
- String returnType = DEFAULT_CAPS + name;
- if (isRootNode) {
- returnType = name + OP_PARAM;
- }
- builder.append(methodSignature(
- returnType, EMPTY_STRING, PROTECTED, BUILDER_LOWER_CASE + OBJECT,
- null, name + BUILDER, CLASS_TYPE));
- return builder.toString();
- }
-
- /**
* Returns the constructor strings for class file.
*
* @param attr attribute info
@@ -738,7 +674,7 @@
attrCaps, EIGHT_SPACE_INDENTATION, GET, null,
false, null);
default:
- return methodBody(MethodBodyTypes.CONSTRUCTOR, attrName,
+ return methodBody(MethodBodyTypes.DEFAULT_CONSTRUCTOR, null,
attrName, EIGHT_SPACE_INDENTATION, EMPTY_STRING,
null, false, null);
}
@@ -764,27 +700,6 @@
}
/**
- * Returns the build method strings for class file.
- *
- * @param yangName class name
- * @param isRootNode if root node
- * @return build method string for class
- */
- static String getBuild(String yangName, boolean isRootNode) {
- String type = DEFAULT_CAPS + yangName;
- if (isRootNode) {
- type = yangName + OP_PARAM;
- }
- return methodSignature(BUILD, EMPTY_STRING, PUBLIC, null,
- yangName, null,
- CLASS_TYPE) +
- methodBody(MethodBodyTypes.BUILD, type, BUILD,
- EIGHT_SPACE_INDENTATION, EMPTY_STRING,
- null, false, null) +
- methodClose(FOUR_SPACE);
- }
-
- /**
* Returns the Default constructor strings for class file.
*
* @param name name of the class
@@ -878,7 +793,7 @@
static String getToStringMethodClose() {
return TWELVE_SPACE_INDENTATION + PERIOD + TO_STRING_METHOD +
brackets(OPEN_CLOSE_BRACKET, null, null) + signatureClose() +
- methodClose(FOUR_SPACE);
+ methodClose(FOUR_SPACE) + NEW_LINE;
}
/**
@@ -1537,16 +1452,16 @@
param.put(attr.getAttributeName() + KEYS, retType + KEYS);
param.put(attr.getAttributeName() + VALUE_CAPS, retType);
return multiAttrMethodSignature(methodName, null, null,
- className + BUILDER, param,
+ className, param,
INTERFACE_TYPE);
default:
return methodSignature(methodName, null, null, ADD_STRING + TO_CAPS,
- className + BUILDER, retType,
+ className, retType,
INTERFACE_TYPE);
}
}
return methodSignature(methodName, null, null, ADD_STRING + TO_CAPS,
- className + BUILDER, getReturnType(attr),
+ className, getReturnType(attr),
INTERFACE_TYPE);
}
@@ -1590,7 +1505,7 @@
param.put(attr.getAttributeName() + VALUE_CAPS, retType);
builder.append(multiAttrMethodSignature(methodName,
null, PUBLIC,
- name + BUILDER, param,
+ name, param,
CLASS_TYPE))
.append(getIfConditionForAddToListMethod(attr));
retString = EIGHT_SPACE_INDENTATION + attrName + PERIOD +
@@ -1602,17 +1517,18 @@
builder.append(methodSignature(methodName,
null, PUBLIC,
ADD_STRING + TO_CAPS,
- name + BUILDER, retType,
+ name, retType,
CLASS_TYPE))
.append(getIfConditionForAddToListMethod(attr));
retString = EIGHT_SPACE_INDENTATION + attrName + PERIOD + ADD_STRING +
OPEN_PARENTHESIS + ADD_STRING + TO_CAPS + CLOSE_PARENTHESIS;
+
}
} else {
builder.append(methodSignature(ADD_STRING + TO_CAPS +
getCapitalCase(attrName),
null, PUBLIC, ADD_STRING + TO_CAPS,
- name + BUILDER, retType,
+ name, retType,
CLASS_TYPE))
.append(getIfConditionForAddToListMethod(attr));
retString = EIGHT_SPACE_INDENTATION + attrName + PERIOD + ADD_STRING +
@@ -1624,6 +1540,7 @@
.append(signatureClose())
.append(methodClose(FOUR_SPACE));
return builder.toString();
+
}
// Returns if condition for add to list method.
@@ -1653,6 +1570,7 @@
default:
type = ARRAY_LIST_INIT;
break;
+
}
} else {
type = ARRAY_LIST_INIT;
@@ -1665,23 +1583,6 @@
}
/**
- * Returns builder method for class.
- *
- * @param name name of class
- * @return builder method for class
- */
- static String builderMethod(String name) {
- return generateForBuilderMethod(name) +
- methodSignature(BUILDER_LOWER_CASE,
- EMPTY_STRING, PUBLIC + SPACE +
- STATIC, null, name + BUILDER, null, CLASS_TYPE) +
- getReturnString(NEW + SPACE + name + BUILDER,
- EIGHT_SPACE_INDENTATION) +
- brackets(OPEN_CLOSE_BRACKET, null, null) + signatureClose() +
- methodClose(FOUR_SPACE);
- }
-
- /**
* Returns is value set interface.
*
* @return is value set interface
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/StringGenerator.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/StringGenerator.java
index d381805..f2cccb8 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/StringGenerator.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/StringGenerator.java
@@ -47,7 +47,6 @@
import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getYangDataStructure;
import static org.onosproject.yang.compiler.utils.UtilConstants.ADD_STRING;
import static org.onosproject.yang.compiler.utils.UtilConstants.AND;
-import static org.onosproject.yang.compiler.utils.UtilConstants.APPEND;
import static org.onosproject.yang.compiler.utils.UtilConstants.APP_INSTANCE;
import static org.onosproject.yang.compiler.utils.UtilConstants.AT;
import static org.onosproject.yang.compiler.utils.UtilConstants.BIG_DECIMAL;
@@ -55,8 +54,6 @@
import static org.onosproject.yang.compiler.utils.UtilConstants.BITSET;
import static org.onosproject.yang.compiler.utils.UtilConstants.BOOLEAN_DATA_TYPE;
import static org.onosproject.yang.compiler.utils.UtilConstants.BOOLEAN_WRAPPER;
-import static org.onosproject.yang.compiler.utils.UtilConstants.BUILDER;
-import static org.onosproject.yang.compiler.utils.UtilConstants.BUILDER_LOWER_CASE;
import static org.onosproject.yang.compiler.utils.UtilConstants.BYTE;
import static org.onosproject.yang.compiler.utils.UtilConstants.BYTE_WRAPPER;
import static org.onosproject.yang.compiler.utils.UtilConstants.CATCH;
@@ -333,13 +330,9 @@
builder.append(body);
}
return builder.toString();
- case BUILD:
- return getReturnString(
- NEW + SPACE + paraName + getOpenCloseParaWithValue(
- THIS) + signatureClose(), space);
case CONSTRUCTOR:
return space + paraName + SPACE +
- EQUAL + SPACE + BUILDER_LOWER_CASE + OBJECT + PERIOD +
+ EQUAL + SPACE + OBJECT + PERIOD +
prefix + methodName +
brackets(OPEN_CLOSE_BRACKET, null, null) +
signatureClose();
@@ -1063,17 +1056,6 @@
}
/**
- * Returns builder string for class definition.
- *
- * @param yangName class name
- * @return builder string for class definition
- */
- static String getBuilderImplStringClassDef(String yangName) {
- return new StringBuilder(yangName).append(PERIOD).append(yangName)
- .append(BUILDER).toString();
- }
-
- /**
* Returns default name string.
*
* @param yangName class name
@@ -1139,18 +1121,6 @@
}
/**
- * Returns string builder's append string.
- *
- * @param append data to be append
- * @param space indentation
- * @return string builder's append string
- */
- static String getStringBuilderAppendString(String append, String space) {
- return space + STRING_BUILDER_VAR + PERIOD + APPEND + OPEN_PARENTHESIS +
- append + CLOSE_PARENTHESIS + signatureClose();
- }
-
- /**
* Returns pattern quote string.
*
* @param type type for pattern is needed
diff --git a/compiler/base/translator/src/test/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGeneratorTest.java b/compiler/base/translator/src/test/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGeneratorTest.java
index 45fd00e..75ad047 100644
--- a/compiler/base/translator/src/test/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGeneratorTest.java
+++ b/compiler/base/translator/src/test/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGeneratorTest.java
@@ -99,34 +99,6 @@
}
/**
- * Test for build method for class.
- */
- @Test
- public void getBuildTest() {
- String method = MethodsGenerator.getBuild(CLASS_NAME, false);
- assertThat(true, is(method.equals(
- UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE + CLASS_NAME + UtilConstants.SPACE +
- UtilConstants.BUILD + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE +
- UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION +
- UtilConstants.RETURN + UtilConstants.SPACE + UtilConstants.NEW + UtilConstants.SPACE + UtilConstants.DEFAULT_CAPS + CLASS_NAME +
- UtilConstants.OPEN_PARENTHESIS + UtilConstants.THIS + UtilConstants.CLOSE_PARENTHESIS +
- UtilConstants.SEMI_COLON + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION +
- UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE)));
- }
-
- /**
- * Test for build method of interface.
- */
- @Test
- public void getBuildForInterfaceTest() {
- String method = MethodsGenerator.getBuildForInterface(CLASS_NAME);
- assertThat(true, is(method.equals(
- UtilConstants.FOUR_SPACE_INDENTATION + CLASS_NAME + UtilConstants.SPACE + UtilConstants.BUILD +
- UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLON +
- UtilConstants.NEW_LINE)));
- }
-
- /**
* Test for check not null method.
*/
@Test
@@ -139,34 +111,6 @@
}
/**
- * Test case for constructor.
- */
- @Test
- public void getConstructorTest() {
- JavaAttributeInfo testAttr = getTestAttribute();
- String method = MethodsGenerator.getConstructor(testAttr, GeneratedJavaFileType.GENERATE_SERVICE_AND_MANAGER
- );
- assertThat(true, is(method.contains(
- ATTRIBUTE_NAME + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE +
- UtilConstants.BUILDER_LOWER_CASE + UtilConstants.OBJECT + UtilConstants.PERIOD +
- UtilConstants.GET_METHOD_PREFIX + CLASS_NAME + UtilConstants.OPEN_PARENTHESIS +
- UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLON)));
- }
-
- /**
- * Test for constructor start method.
- */
- @Test
- public void getConstructorStartTest() {
- String method = MethodsGenerator.getConstructorStart(CLASS_NAME, false);
- assertThat(true, is(method.contains(
- UtilConstants.PROTECTED + UtilConstants.SPACE + UtilConstants.DEFAULT_CAPS + CLASS_NAME +
- UtilConstants.OPEN_PARENTHESIS + CLASS_NAME + UtilConstants.BUILDER + UtilConstants.SPACE +
- UtilConstants.BUILDER_LOWER_CASE + UtilConstants.OBJECT + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE +
- UtilConstants.OPEN_CURLY_BRACKET)));
- }
-
- /**
* Test case for equals method.
*/
@Test
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 8f5131b..8659dd8 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
@@ -33,12 +33,6 @@
" * Represents the implementation of ";
/**
- * JavaDocs for builder class.
- */
- public static final String BUILDER_CLASS_JAVA_DOC =
- " * Represents the builder implementation of ";
-
- /**
* JavaDocs for interface class.
*/
public static final String INTERFACE_JAVA_DOC =
@@ -64,11 +58,6 @@
" * Abstraction for event listener of ";
/**
- * JavaDocs for builder interface class.
- */
- public static final String BUILDER_INTERFACE_JAVA_DOC = " * Builder for ";
-
- /**
* JavaDocs for enum class.
*/
public static final String ENUM_CLASS_JAVADOC =
@@ -115,7 +104,7 @@
* JavaDocs's description for setter method.
*/
public static final String JAVA_DOC_SETTERS =
- " * Returns the builder object of ";
+ " * Sets the attribute ";
/**
* JavaDocs's description for add to list method.
@@ -168,11 +157,6 @@
public static final String JAVA_DOC_BUILD = " * Builds object of ";
/**
- * JavaDocs's statement for builder object.
- */
- public static final String BUILDER_OBJECT = "builder object of ";
-
- /**
* JavaDocs's statement for rpc method.
*/
public static final String JAVA_DOC_RPC = " * Service interface of ";
@@ -249,11 +233,6 @@
public static final String ENTRY = "Entry";
/**
- * Static attribute for period.
- */
- public static final String ENTRY_SET = "entrySet()";
-
- /**
* Static attribute for compare to.
*/
public static final String COMPARE_TO = "compareTo";
@@ -1249,16 +1228,6 @@
public static final String CLASS = "class";
/**
- * Static attribute for builder syntax.
- */
- public static final String BUILDER = "Builder";
-
- /**
- * Static attribute for builder syntax.
- */
- public static final String BUILDER_LOWER_CASE = "builder";
-
- /**
* Static attribute for service syntax.
*/
public static final String SERVICE = "Service";
@@ -1354,16 +1323,6 @@
public static final String EVENT_SUBJECT_NAME_SUFFIX = "EventSubject";
/**
- * Static attribute for build method syntax.
- */
- public static final String BUILD = "build";
-
- /**
- * Static attribute for build for filter in augment method syntax.
- */
- public static final String BUILD_FOR_FILTER = "buildForFilter";
-
- /**
* Static attribute for object.
*/
public static final String OBJECT = "Object";
@@ -1735,16 +1694,6 @@
public static final String RPC_CLASS = "rpc class";
/**
- * Static attribute for builder class.
- */
- public static final String BUILDER_CLASS = "builder class";
-
- /**
- * Static attribute for builder interface.
- */
- public static final String BUILDER_INTERFACE = "builder interface";
-
- /**
* Static attribute for bits.
*/
public static final String BITS = "bits";
diff --git a/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGen.java b/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGen.java
index 07af02e..12256c7 100644
--- a/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGen.java
+++ b/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGen.java
@@ -16,10 +16,59 @@
package org.onosproject.yang.compiler.utils.io.impl;
-import org.onosproject.yang.compiler.utils.UtilConstants;
-
-import static org.onosproject.yang.compiler.utils.UtilConstants.*;
-import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.*;
+import static org.onosproject.yang.compiler.utils.UtilConstants.ADD_STRING;
+import static org.onosproject.yang.compiler.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
+import static org.onosproject.yang.compiler.utils.UtilConstants.EMPTY_STRING;
+import static org.onosproject.yang.compiler.utils.UtilConstants.ENUM_ATTRIBUTE_JAVADOC;
+import static org.onosproject.yang.compiler.utils.UtilConstants.ENUM_CLASS_JAVADOC;
+import static org.onosproject.yang.compiler.utils.UtilConstants.EVENT_JAVA_DOC;
+import static org.onosproject.yang.compiler.utils.UtilConstants.EVENT_LISTENER_JAVA_DOC;
+import static org.onosproject.yang.compiler.utils.UtilConstants.FOUR_SPACE_INDENTATION;
+import static org.onosproject.yang.compiler.utils.UtilConstants.FROM_STRING_METHOD_NAME;
+import static org.onosproject.yang.compiler.utils.UtilConstants.FROM_STRING_PARAM_NAME;
+import static org.onosproject.yang.compiler.utils.UtilConstants.IMPL_CLASS_JAVA_DOC;
+import static org.onosproject.yang.compiler.utils.UtilConstants.INPUT;
+import static org.onosproject.yang.compiler.utils.UtilConstants.INTERFACE_JAVA_DOC;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_ADD_TO_LIST;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_CONSTRUCTOR;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_END_LINE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_FIRST_LINE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_FOR_VALIDATOR;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_FOR_VALIDATOR_RETURN;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_GETTERS;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_MANAGER_SETTERS;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_OF;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_PARAM;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_RETURN;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_RPC;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_SETTERS;
+import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_DOC_SETTERS_COMMON;
+import static org.onosproject.yang.compiler.utils.UtilConstants.KEYS;
+import static org.onosproject.yang.compiler.utils.UtilConstants.LIST;
+import static org.onosproject.yang.compiler.utils.UtilConstants.MAP;
+import static org.onosproject.yang.compiler.utils.UtilConstants.MAX_RANGE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.MIN_RANGE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.NEW_LINE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.NEW_LINE_ASTERISK;
+import static org.onosproject.yang.compiler.utils.UtilConstants.OBJECT;
+import static org.onosproject.yang.compiler.utils.UtilConstants.OF;
+import static org.onosproject.yang.compiler.utils.UtilConstants.OP_PARAM_JAVA_DOC;
+import static org.onosproject.yang.compiler.utils.UtilConstants.PACKAGE_INFO_JAVADOC;
+import static org.onosproject.yang.compiler.utils.UtilConstants.PACKAGE_INFO_JAVADOC_OF_CHILD;
+import static org.onosproject.yang.compiler.utils.UtilConstants.PERIOD;
+import static org.onosproject.yang.compiler.utils.UtilConstants.QUEUE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_INPUT_STRING;
+import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_OUTPUT_STRING;
+import static org.onosproject.yang.compiler.utils.UtilConstants.SET;
+import static org.onosproject.yang.compiler.utils.UtilConstants.SPACE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.STRING_DATA_TYPE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.TO_CAPS;
+import static org.onosproject.yang.compiler.utils.UtilConstants.VALIDATE_RANGE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.VALUE;
+import static org.onosproject.yang.compiler.utils.UtilConstants.VALUE_CAPS;
+import static org.onosproject.yang.compiler.utils.UtilConstants.VOID;
+import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getCapitalCase;
+import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getSmallCase;
/**
* Represents javadoc for the generated classes.
@@ -49,21 +98,12 @@
case DEFAULT_CLASS: {
return generateForClass(name, isList);
}
- case BUILDER_CLASS: {
- return generateForBuilderClass(name);
- }
case OPERATION_CLASS: {
return generateForOpParamClass(name);
}
- case OPERATION_BUILDER_CLASS: {
- return generateForOpParamClass(name);
- }
case INTERFACE: {
return generateForInterface(name);
}
- case BUILDER_INTERFACE: {
- return generateForBuilderInterface(name);
- }
case PACKAGE_INFO: {
return generateForPackage(name, isList);
}
@@ -85,9 +125,6 @@
case DEFAULT_CONSTRUCTOR: {
return generateForDefaultConstructors(name);
}
- case BUILD_METHOD: {
- return generateForBuild(name);
- }
case TYPE_CONSTRUCTOR: {
return generateForTypeConstructor(name);
}
@@ -262,8 +299,7 @@
getJavaDocEmptyAsteriskLine() +
FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + attribute + SPACE;
setter = getParamForAnnotation(setter, compilerAnnotation, isList) +
- attribute + NEW_LINE + getJavaDocReturnLine(attribute)
- + getJavaDocEndLine();
+ attribute + NEW_LINE + getJavaDocEndLine();
return setter;
}
@@ -400,17 +436,6 @@
}
/**
- * Generates javaDocs for the builder class.
- *
- * @param className class name
- * @return javaDocs
- */
- private static String generateForBuilderClass(String className) {
- return getJavaDocForClass(className, BUILDER_CLASS_JAVA_DOC,
- EMPTY_STRING);
- }
-
- /**
* Generates javaDocs for the op param class.
*
* @param className class name
@@ -433,17 +458,6 @@
}
/**
- * Generates javaDoc for the builder interface.
- *
- * @param builderForName builder for name
- * @return javaDocs
- */
- private static String generateForBuilderInterface(String builderForName) {
- return getJavaDocForClass(builderForName, BUILDER_INTERFACE_JAVA_DOC,
- EMPTY_STRING);
- }
-
- /**
* Generates javaDocs for package-info.
*
* @param packageName package name
@@ -479,22 +493,7 @@
private static String generateForConstructors(String className) {
return getJavaDocStartLine(className, JAVA_DOC_CONSTRUCTOR) +
getJavaDocEmptyAsteriskLine() +
- getJavaDocParamLine(BUILDER_OBJECT + className,
- BUILDER_LOWER_CASE + OBJECT) +
- getJavaDocEndLine();
- }
-
- /**
- * Generates javaDocs for build.
- *
- * @param buildName builder name
- * @return javaDocs
- */
- private static String generateForBuild(String buildName) {
- return getJavaDocStartLine(buildName, JAVA_DOC_BUILD) +
- getJavaDocEmptyAsteriskLine() +
- getJavaDocReturnLine(buildName) +
- getJavaDocEndLine();
+ getJavaDocParamLine(className, OBJECT) + getJavaDocEndLine();
}
/**
@@ -568,25 +567,12 @@
}
javadoc.append(getJavaDocParamLine(
attribute, ADD_STRING + TO_CAPS))
- .append(getJavaDocReturnLine(BUILDER_OBJECT + attribute))
+ .append(getJavaDocReturnLine(attribute))
.append(getJavaDocEndLine());
return javadoc.toString();
}
/**
- * Generates for builder method.
- *
- * @param attribute attribute
- * @return javaDocs
- */
- public static String generateForBuilderMethod(String attribute) {
- return getJavaDocStartLine(attribute + BUILDER, JAVA_DOC_GETTERS) +
- getJavaDocEmptyAsteriskLine() +
- getJavaDocReturnLine(attribute + BUILDER) +
- getJavaDocEndLine();
- }
-
- /**
* Returns class javadoc.
*
* @param name name of class
@@ -686,21 +672,11 @@
DEFAULT_CLASS,
/**
- * For builder class.
- */
- BUILDER_CLASS,
-
- /**
* For interface.
*/
INTERFACE,
/**
- * For builder interface.
- */
- BUILDER_INTERFACE,
-
- /**
* For package-info.
*/
PACKAGE_INFO,
@@ -796,11 +772,6 @@
OPERATION_CLASS,
/**
- * For operation builder.
- */
- OPERATION_BUILDER_CLASS,
-
- /**
* For add to list.
*/
ADD_TO_LIST,
diff --git a/compiler/base/utils/src/test/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGenTest.java b/compiler/base/utils/src/test/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGenTest.java
index 9da07d0..3402aaa 100644
--- a/compiler/base/utils/src/test/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGenTest.java
+++ b/compiler/base/utils/src/test/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGenTest.java
@@ -27,9 +27,6 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
-import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_CLASS;
-import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_INTERFACE;
-import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CLASS;
import static org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR;
@@ -52,36 +49,6 @@
public ExpectedException thrown = ExpectedException.none();
/**
- * This test case checks the content received for the builder class java doc.
- */
- @Test
- public void builderClassGenerationTest() {
- String builderClassJavaDoc = getJavaDoc(BUILDER_CLASS, TEST_NAME, false, null);
- assertThat(true, is(builderClassJavaDoc.contains("Represents the builder implementation of")
- && builderClassJavaDoc.contains(END_STRING)));
- }
-
- /**
- * This test case checks the content received for the builder interface ge java doc.
- */
- @Test
- public void builderInterfaceGenerationTest() {
- String builderInterfaceJavaDoc = getJavaDoc(BUILDER_INTERFACE, TEST_NAME, false, null);
- assertThat(true,
- is(builderInterfaceJavaDoc.contains("Builder for")
- && builderInterfaceJavaDoc.contains(END_STRING)));
- }
-
- /**
- * This test case checks the content received for the build java doc.
- */
- @Test
- public void buildGenerationTest() {
- String buildDoc = getJavaDoc(BUILD_METHOD, TEST_NAME, false, null);
- assertThat(true, is(buildDoc.contains("Builds object of") && buildDoc.contains(END_STRING)));
- }
-
- /**
* A private constructor is tested.
*
* @throws SecurityException if any security violation is observed
@@ -112,7 +79,7 @@
String constructorDoc = getJavaDoc(CONSTRUCTOR, TEST_NAME, false, null);
assertThat(true,
is(constructorDoc.contains("Creates an instance of ")
- && constructorDoc.contains("builder object of")
+ && constructorDoc.contains("object value of")
&& constructorDoc.contains("@param") && constructorDoc.contains("*/\n")));
}
@@ -185,7 +152,8 @@
public void setterGenerationTest() {
String setterJavaDoc = getJavaDoc(SETTER_METHOD, TEST_NAME, false, null);
assertThat(true,
- is(setterJavaDoc.contains("Returns the builder object of") && setterJavaDoc.contains(END_STRING)));
+ is(setterJavaDoc.contains("Sets the attribute") &&
+ setterJavaDoc.contains(END_STRING)));
}
/**