[ONOS-5539] Process sub tree defect fix
Change-Id: I6e06a8ca430a86cc538543b161bbbc56dc9cade6
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
index 93720fd..17976e6 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
@@ -410,8 +410,7 @@
public void detectCollidingChild(String idName, YangConstructType type)
throws DataModelException {
- if (getParent() instanceof YangCase &&
- type != CASE_DATA) {
+ if (getParent() instanceof YangCase && type != CASE_DATA) {
((CollisionDetector) getParent()).detectCollidingChild(idName, type);
}
YangNode node = getChild();
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
index 76a10e1..26fcbd4 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
@@ -32,7 +32,7 @@
/**
* Represents base class of a node in data model tree.
*/
-public abstract class YangNode extends DefaultLocationInfo
+public abstract class YangNode
implements Cloneable, Serializable, YangSchemaNode,
Comparable<YangNode> {
@@ -78,10 +78,9 @@
*/
private boolean isToTranslate = true;
- /**
- * Flag if the node needs to generate operation type info for translation.
- */
- private boolean isOpTypeReq;
+ private transient int lineNumber;
+ private transient int charPosition;
+ private String fileName;
/**
* Map of YANG context information. It is to be consumed by YMS.
@@ -146,7 +145,7 @@
*/
protected YangNode(YangNodeType type,
Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> ysnContextInfoMap) {
- setNodeType(type);
+ nodeType = type;
this.ysnContextInfoMap = ysnContextInfoMap;
}
@@ -889,14 +888,38 @@
* @return true if op type info required for node
*/
public boolean isOpTypeReq() {
- if (this instanceof RpcNotificationContainer) {
- isOpTypeReq = true;
- return true;
- }
- if (this instanceof InvalidOpTypeHolder) {
- isOpTypeReq = false;
- return false;
- }
- return this.getParent().isOpTypeReq();
+ return this instanceof RpcNotificationContainer ||
+ !(this instanceof InvalidOpTypeHolder) &&
+ getParent().isOpTypeReq();
+ }
+
+ @Override
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
+ @Override
+ public int getCharPosition() {
+ return charPosition;
+ }
+
+ @Override
+ public void setLineNumber(int lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
+ @Override
+ public void setCharPosition(int charPositionInLine) {
+ charPosition = charPositionInLine;
+ }
+
+ @Override
+ public String getFileName() {
+ return fileName;
+ }
+
+ @Override
+ public void setFileName(String name) {
+ fileName = name;
}
}
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangType.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
index 05063d3..ad9c4f5 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
@@ -31,6 +31,8 @@
import java.util.ListIterator;
import static org.onosproject.yangutils.datamodel.BuiltInTypeObjectFactory.getDataObjectFromString;
+import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.UNRESOLVED;
+import static org.onosproject.yangutils.datamodel.utils.YangConstructType.TYPE_DATA;
import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypeUtils.isOfRangeRestrictedType;
import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.DERIVED;
@@ -71,7 +73,7 @@
/**
* YANG node identifier.
*/
- private YangNodeIdentifier nodeIdentifier;
+ private YangNodeIdentifier nodeId;
/**
* YANG data type.
@@ -109,8 +111,8 @@
*/
public YangType() {
- nodeIdentifier = new YangNodeIdentifier();
- resolvableStatus = ResolvableStatus.UNRESOLVED;
+ nodeId = new YangNodeIdentifier();
+ resolvableStatus = UNRESOLVED;
}
/**
@@ -119,7 +121,7 @@
* @return prefix associated with data type name
*/
public String getPrefix() {
- return nodeIdentifier.getPrefix();
+ return nodeId.getPrefix();
}
/**
@@ -128,7 +130,7 @@
* @param prefix prefix associated with data type name
*/
public void setPrefix(String prefix) {
- nodeIdentifier.setPrefix(prefix);
+ nodeId.setPrefix(prefix);
}
/**
@@ -137,7 +139,7 @@
* @return the name of data type
*/
public String getDataTypeName() {
- return nodeIdentifier.getName();
+ return nodeId.getName();
}
/**
@@ -146,7 +148,7 @@
* @param typeName the name to set
*/
public void setDataTypeName(String typeName) {
- nodeIdentifier.setName(typeName);
+ nodeId.setName(typeName);
}
/**
@@ -190,25 +192,25 @@
*
* @return node identifier
*/
- public YangNodeIdentifier getNodeIdentifier() {
- return nodeIdentifier;
+ public YangNodeIdentifier getNodeId() {
+ return nodeId;
}
/**
* Sets node identifier.
*
- * @param nodeIdentifier the node identifier
+ * @param nodeId the node identifier
*/
- public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) {
- this.nodeIdentifier = nodeIdentifier;
+ public void setNodeId(YangNodeIdentifier nodeId) {
+ this.nodeId = nodeId;
}
/**
* Resets the class attributes to its default value.
*/
public void resetYangType() {
- nodeIdentifier = new YangNodeIdentifier();
- resolvableStatus = ResolvableStatus.UNRESOLVED;
+ nodeId = new YangNodeIdentifier();
+ resolvableStatus = UNRESOLVED;
dataType = null;
dataTypeExtendedInfo = null;
}
@@ -220,7 +222,7 @@
*/
@Override
public YangConstructType getYangConstructType() {
- return YangConstructType.TYPE_DATA;
+ return TYPE_DATA;
}
/**
@@ -429,18 +431,24 @@
}
}
} else if (dataType == YangDataTypes.STRING) {
- if (((YangDerivedInfo) getDataTypeExtendedInfo()).getResolvedExtendedInfo() != null) {
- YangStringRestriction stringRestriction =
- ((YangStringRestriction) ((YangDerivedInfo) getDataTypeExtendedInfo())
- .getResolvedExtendedInfo());
- if (!(stringRestriction.isValidStringOnLengthRestriction(value) &&
- stringRestriction.isValidStringOnPatternRestriction(value))) {
- throw new DataTypeException("YANG file error : Input value \"" + value
- + "\" is not a valid " + dataType);
+ Object info = ((YangDerivedInfo) getDataTypeExtendedInfo())
+ .getResolvedExtendedInfo();
+ if (info != null) {
+ if (info instanceof YangStringRestriction) {
+ YangStringRestriction stringRestriction =
+ (YangStringRestriction) info;
+ if (!(stringRestriction.isValidStringOnLengthRestriction(value) &&
+ stringRestriction.isValidStringOnPatternRestriction(value))) {
+ throw new DataTypeException("YANG file error : Input value \"" + value
+ + "\" is not a valid " + dataType);
+ }
}
}
} else if (dataType == YangDataTypes.BITS) {
- YangBits bits = (YangBits) getDataTypeExtendedInfo();
+ YangTypeDef prevTypedef = ((YangDerivedInfo) getDataTypeExtendedInfo())
+ .getReferredTypeDef();
+ YangType type = prevTypedef.getTypeList().iterator().next();
+ YangBits bits = (YangBits) type.getDataTypeExtendedInfo();
if (bits.fromString(value) == null) {
throw new DataTypeException("YANG file error : Input value \"" + value + "\" is not a valid " +
dataType);
diff --git a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
index cfcd3e7..c169250 100644
--- a/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
+++ b/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
@@ -322,7 +322,8 @@
* @return de-serializes YANG data-model nodes
* @throws IOException when fails do IO operations
*/
- private static Set<YangNode> deSerializeDataModel(String serializedFileInfo) throws IOException {
+ public static Set<YangNode> deSerializeDataModel(String serializedFileInfo)
+ throws IOException {
Set<YangNode> nodes;
try {
diff --git a/generator/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerUtils.java b/generator/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerUtils.java
index aa55b96..3c1fed0 100644
--- a/generator/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerUtils.java
+++ b/generator/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerUtils.java
@@ -49,7 +49,9 @@
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
@@ -201,13 +203,19 @@
augment.setChild(null);
for (YangNode node : childNodes) {
- YangCase javaCase = getYangCaseNode(JAVA_GENERATION);
- javaCase.setName(node.getName());
- augment.addChild(javaCase);
- node.setParent(javaCase);
+ Map<YangNode, List<YangNode>> map = new LinkedHashMap<>();
node.setNextSibling(null);
node.setPreviousSibling(null);
+ node.setParent(null);
+ YangCase javaCase = getYangCaseNode(JAVA_GENERATION);
+ javaCase.setName(node.getName());
+ //Break the tree to from a new tree.
+ traverseAndBreak(node, map);
+ augment.addChild(javaCase);
+ node.setParent(javaCase);
javaCase.addChild(node);
+ //Connect each node to its correct parent again.
+ connectTree(map);
}
if (augment.getListOfLeaf() != null) {
for (YangLeaf leaf : augment.getListOfLeaf()) {
@@ -237,6 +245,63 @@
}
}
+ private static void connectTree(Map<YangNode, List<YangNode>> map)
+ throws DataModelException {
+ ArrayList<YangNode> keys = new ArrayList<>(map.keySet());
+ int size = keys.size();
+ for (int i = size - 1; i >= 0; i--) {
+ YangNode curNode = keys.get(i);
+ List<YangNode> nodes = map.get(curNode);
+ if (nodes != null) {
+ for (YangNode node : nodes) {
+ curNode.addChild(node);
+ }
+ }
+ }
+ map.clear();
+ }
+
+ private static void processHierarchyChild(YangNode node,
+ Map<YangNode, List<YangNode>> map) {
+ YangNode child = node.getChild();
+ if (child != null) {
+ List<YangNode> nodes = new ArrayList<>();
+ while (child != null) {
+ nodes.add(child);
+ child.setParent(null);
+ child = child.getNextSibling();
+ if (child != null) {
+ child.getPreviousSibling().setNextSibling(null);
+ child.setPreviousSibling(null);
+ }
+ }
+ map.put(node, nodes);
+ }
+ node.setChild(null);
+ }
+
+ private static void traverseAndBreak(YangNode rootNode,
+ Map<YangNode, List<YangNode>> map) {
+
+ YangNode curNode = rootNode;
+ TraversalType curTraversal = ROOT;
+ while (curNode != null) {
+ if (curTraversal != PARENT && curNode.getChild() != null) {
+ curTraversal = CHILD;
+ curNode = curNode.getChild();
+ } else if (curNode.getNextSibling() != null) {
+ curTraversal = SIBILING;
+ curNode = curNode.getNextSibling();
+ } else {
+ curTraversal = PARENT;
+ curNode = curNode.getParent();
+ if (curNode != null) {
+ processHierarchyChild(curNode, map);
+ }
+ }
+ }
+ }
+
/**
* Returns error messages.
*
diff --git a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
index 00a7baf..7f6eb84 100644
--- a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
+++ b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
@@ -20,12 +20,12 @@
import org.onosproject.yangutils.datamodel.YangAugmentableNode;
import org.onosproject.yangutils.datamodel.YangCase;
import org.onosproject.yangutils.datamodel.YangChoice;
-import org.onosproject.yangutils.datamodel.YangGrouping;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangLeavesHolder;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangSchemaNode;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.javadatamodel.JavaFileInfo;
import org.onosproject.yangutils.datamodel.javadatamodel.JavaQualifiedTypeInfo;
@@ -114,8 +114,10 @@
import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE;
+import static org.onosproject.yangutils.utils.UtilConstants.INVOCATION_TARGET_EXCEPTION;
import static org.onosproject.yangutils.utils.UtilConstants.INVOCATION_TARGET_EXCEPTION_IMPORT;
import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_PKG;
+import static org.onosproject.yangutils.utils.UtilConstants.METHOD;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.OPERATION_TYPE_ATTRIBUTE;
import static org.onosproject.yangutils.utils.UtilConstants.OPERATION_TYPE_CLASS;
@@ -123,6 +125,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
import static org.onosproject.yangutils.utils.UtilConstants.PROTECTED;
+import static org.onosproject.yangutils.utils.UtilConstants.REFLECT_IMPORTS;
import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF;
import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
@@ -134,6 +137,7 @@
import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ADD_TO_LIST;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD;
import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
@@ -606,10 +610,20 @@
TempJavaBeanFragmentFiles tempFiles =
getBeanFiles((JavaCodeGeneratorInfo) parent);
tempFiles.setAttrNode(curNode);
-
- JavaAttributeInfo attr =
- getCurNodeAsAttributeInTarget(curNode, parent, isList,
- tempFiles);
+ if (curNode instanceof YangChoice) {
+ JavaQualifiedTypeInfoTranslator info = new
+ JavaQualifiedTypeInfoTranslator();
+ info.setClassInfo(INVOCATION_TARGET_EXCEPTION);
+ info.setPkgInfo(REFLECT_IMPORTS);
+ tempFiles.addToSubTreeImports(info);
+ info = new
+ JavaQualifiedTypeInfoTranslator();
+ info.setClassInfo(METHOD);
+ info.setPkgInfo(REFLECT_IMPORTS);
+ tempFiles.addToSubTreeImports(info);
+ }
+ JavaAttributeInfo attr = getCurNodeAsAttributeInTarget(
+ curNode, parent, isList, tempFiles);
tempFiles.addJavaSnippetInfoToApplicableTempFiles(attr, config);
}
@@ -763,16 +777,10 @@
container.getDataType(),
tempFiles.getIsQualifiedAccessOrAddToImportList(
container.getJavaQualifiedInfo()), listAttribute);
- boolean isInGrouping;
- if (container.isLeafList()) {
- isInGrouping = !(((YangLeafList) container).getContainedIn()
- instanceof YangGrouping);
- } else {
- isInGrouping = !(((YangLeaf) container).getContainedIn()
- instanceof YangGrouping);
- }
- if (container.getDataType().getDataType() == YangDataTypes.BITS &&
- isInGrouping) {
+ boolean condition =
+ ((YangSchemaNode) container).getReferredSchema() == null &&
+ container.getDataType().getDataType() == YangDataTypes.BITS;
+ if (condition) {
addBitsHandler(attr, container.getDataType(), tempFiles);
}
return attr;
@@ -1094,7 +1102,12 @@
throws IOException {
String setter = getSetterForClass(attr, getGeneratedJavaClassName(),
getGeneratedJavaFiles());
- appendToFile(setterImplTempFileHandle, getOverRideString() + setter);
+ String javadoc = getOverRideString();
+ if (attr.getAttributeName().equals(SUBTREE_FILTERED)) {
+ javadoc = getJavaDoc(SETTER_METHOD, attr.getAttributeName(),
+ false, null);
+ }
+ appendToFile(setterImplTempFileHandle, javadoc + setter);
}
/**
@@ -1106,9 +1119,13 @@
protected void addGetterImpl(JavaAttributeInfo attr)
throws IOException {
String getter = getGetterForClass(attr, getGeneratedJavaFiles());
+ String javadoc = getOverRideString();
+ if (attr.getAttributeName().equals(SUBTREE_FILTERED)) {
+ javadoc = getJavaDoc(GETTER_METHOD, attr.getAttributeName(),
+ false, null);
+ }
if (javaFlagSet(BUILDER_CLASS_MASK)) {
- appendToFile(getterImplTempFileHandle, getOverRideString() +
- getter);
+ appendToFile(getterImplTempFileHandle, javadoc + getter);
} else {
String appDataStructure = null;
if (attr.getCompilerAnnotation() != null) {
@@ -1531,8 +1548,8 @@
new JavaQualifiedTypeInfoTranslator();
typeInfo.setClassInfo(BIT_SET);
typeInfo.setPkgInfo(JAVA_UTIL_PKG);
- this.getJavaImportData().addImportInfo(typeInfo, info.getJavaName(),
- info.getPackage());
+ getJavaImportData().addImportInfo(typeInfo, info.getJavaName(),
+ info.getPackage());
JavaAttributeInfo attributeInfo =
getAttributeInfoForTheData(typeInfo, VALUE_LEAF, null, false, false);
addJavaSnippetInfoToApplicableTempFiles(attributeInfo, config);
@@ -1617,10 +1634,12 @@
if (tempFlagSet(ATTRIBUTES_MASK)) {
addAttribute(newAttrInfo);
}
- if (tempFlagSet(GETTER_FOR_INTERFACE_MASK)) {
+ if (tempFlagSet(GETTER_FOR_INTERFACE_MASK) &&
+ !attrName.equals(SUBTREE_FILTERED)) {
addGetterForInterface(newAttrInfo);
}
- if (tempFlagSet(SETTER_FOR_INTERFACE_MASK) && required) {
+ if (tempFlagSet(SETTER_FOR_INTERFACE_MASK) && required &&
+ !attrName.equals(SUBTREE_FILTERED)) {
addSetterForInterface(newAttrInfo);
}
if (tempFlagSet(SETTER_FOR_CLASS_MASK) && required) {
@@ -1826,13 +1845,10 @@
//Adds import for bitset and base64 list.
private void addBitsAndBase64Imports(YangNode curNode, List<String> imports) {
- if (curNode instanceof YangLeavesHolder) {
- YangLeavesHolder holder = (YangLeavesHolder) curNode;
- String impt = getJavaImportData()
- .getImportForToBitSet();
- if (!holder.getListOfLeaf().isEmpty() &&
- !imports.contains(impt)) {
- imports.add(impt);
+ if (curNode.isOpTypeReq()) {
+ String impt = getJavaImportData().getImportForToBitSet();
+ if (!imports.contains(impt)) {
+ imports.add(getJavaImportData().getImportForToBitSet());
}
}
}
@@ -1890,7 +1906,9 @@
* @param imports list of imports
*/
private void addInvocationExceptionImport(List<String> imports) {
- imports.add(INVOCATION_TARGET_EXCEPTION_IMPORT);
+ if (!imports.contains(INVOCATION_TARGET_EXCEPTION_IMPORT)) {
+ imports.add(INVOCATION_TARGET_EXCEPTION_IMPORT);
+ }
}
/**
diff --git a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/YangJavaModelUtils.java b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/YangJavaModelUtils.java
index 51aec14..8514291 100644
--- a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/YangJavaModelUtils.java
+++ b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/YangJavaModelUtils.java
@@ -233,18 +233,15 @@
TempJavaCodeFragmentFiles translator =
info.getTempJavaCodeFragmentFiles();
-
+ TempJavaBeanFragmentFiles bean = getBeanFiles(info);
if (info instanceof RpcNotificationContainer) {
- getBeanFiles(info).setRootNode(true);
+ bean.setRootNode(true);
/*
* event classes code generation.
*/
updateNotificationNodeInfo(info, config);
}
if (info instanceof YangLeavesHolder) {
- if (info instanceof YangAugment) {
- getBeanFiles(info).addIsSubTreeFilteredFlag(config);
- }
YangLeavesHolder holder = (YangLeavesHolder) info;
boolean isLeafPresent = holder.getListOfLeaf() != null && !holder
@@ -261,20 +258,21 @@
* Output
*/
if (isLeafPresent || isLeafListPresent) {
- getBeanFiles(info).addCurNodeLeavesInfoToTempFiles((YangNode) info,
- config);
+ bean.addCurNodeLeavesInfoToTempFiles((YangNode) info,
+ config);
}
//Add value leaf flag attribute to temp file.
if (isLeafPresent) {
- getBeanFiles(info).addValueLeafFlag(config, (YangNode) info);
+ bean.addValueLeafFlag(config, (YangNode) info);
}
if (((YangNode) info).isOpTypeReq()) {
// Add operation type as an attribute.
- getBeanFiles(info).addOperationTypeToTempFiles((YangNode) info,
- config);
+ bean.addOperationTypeToTempFiles((YangNode) info,
+ config);
+ bean.addIsSubTreeFilteredFlag(config);
if (isLeafPresent) {
//Add select leaf flag attribute to temp file.
- getBeanFiles(info).addSelectLeafFlag(config);
+ bean.addSelectLeafFlag(config);
}
}
} else if (info instanceof YangTypeHolder) {
@@ -433,21 +431,18 @@
}
generateCodeOfNode(info, config);
- TempJavaCodeFragmentFiles tempFiles =
- info.getTempJavaCodeFragmentFiles();
+ TempJavaBeanFragmentFiles tempFiles = getBeanFiles(info);
if (!(info instanceof YangChoice)) {
- getBeanFiles(info).addYangAugmentedMap(config);
+ tempFiles.addYangAugmentedMap(config);
}
if (info instanceof YangCase) {
YangNode parent = ((YangCase) info).getParent();
JavaQualifiedTypeInfoTranslator typeInfo =
getQualifierInfoForCasesParent(parent, config);
- getBeanFiles(info).getJavaExtendsListHolder()
- .addToExtendsList(typeInfo, (YangNode) info,
- tempFiles.getBeanTempFiles());
+ tempFiles.getJavaExtendsListHolder()
+ .addToExtendsList(typeInfo, (YangNode) info, tempFiles);
- getBeanFiles(info).addParentInfoInCurNodeTempFile((YangNode) info,
- config);
+ tempFiles.addParentInfoInCurNodeTempFile((YangNode) info, config);
}
}
@@ -629,7 +624,6 @@
YangPluginConfig config) {
List<String> clsInfo = new ArrayList<>();
- String add = null;
while (node.getParent() != null) {
if (node instanceof YangJavaAugmentTranslator) {
YangJavaAugmentTranslator augment =
@@ -658,9 +652,6 @@
subModule.getRevision(),
config.getConflictResolver()));
}
- if (add != null) {
- clsInfo.add(add);
- }
clsInfo.add(getCamelCase(node.getName(), config.getConflictResolver()));
int size = clsInfo.size();
diff --git a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
index 4f8c94d..7bc490f 100644
--- a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
+++ b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
@@ -17,7 +17,6 @@
package org.onosproject.yangutils.translator.tojava.utils;
import org.onosproject.yangutils.datamodel.RpcNotificationContainer;
-import org.onosproject.yangutils.datamodel.YangAugment;
import org.onosproject.yangutils.datamodel.YangAugmentableNode;
import org.onosproject.yangutils.datamodel.YangChoice;
import org.onosproject.yangutils.datamodel.YangDerivedInfo;
@@ -38,7 +37,6 @@
import org.onosproject.yangutils.translator.tojava.TempJavaEventFragmentFiles;
import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles;
import org.onosproject.yangutils.translator.tojava.TempJavaTypeFragmentFiles;
-import org.onosproject.yangutils.utils.io.YangPluginConfig;
import java.io.File;
import java.io.IOException;
@@ -93,7 +91,7 @@
import static org.onosproject.yangutils.translator.tojava.utils.MethodBodyTypes.ENUM_METHOD_INT_VALUE;
import static org.onosproject.yangutils.translator.tojava.utils.MethodBodyTypes.ENUM_METHOD_STRING_VALUE;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.builderMethod;
-import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.generateBuildMethodInAugmentClass;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.generateBuildMethodForSubTree;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodImpl;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAddAugmentInfoMethodInterface;
import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentsDataMethodForService;
@@ -442,8 +440,8 @@
methods.add(((TempJavaCodeFragmentFilesContainer) curNode)
.getTempJavaCodeFragmentFiles()
.addBuildMethodImpl());
- if (curNode instanceof YangAugment) {
- methods.add(generateBuildMethodInAugmentClass(className));
+ if (curNode.isOpTypeReq()) {
+ methods.add(generateBuildMethodForSubTree(curNode));
}
methods.add(addDefaultConstructor(curNode, PUBLIC, BUILDER));
@@ -472,8 +470,6 @@
JavaFileInfoTranslator fileInfo =
((JavaFileInfoContainer) curNode).getJavaFileInfo();
- YangPluginConfig config = fileInfo.getPluginConfig();
-
boolean leavesPresent;
YangLeavesHolder leavesHolder;
if (curNode instanceof YangLeavesHolder) {
@@ -531,7 +527,7 @@
methods.add(getProcessSubtreeFilteringStart(curNode) +
getProcessSubtreeFunctionBody(curNode) +
augmentableSubTreeFiltering +
- getProcessSubTreeFilteringEnd(name, curNode));
+ getProcessSubTreeFilteringEnd(name));
if (curNode instanceof YangLeavesHolder) {
if (((YangLeavesHolder) curNode).getListOfLeaf() != null &&
@@ -741,11 +737,9 @@
*
* @param curNode current node
* @param methods list of methods string
- * @throws IOException a violation in IO rule
*/
private static void addTypedefToString(YangNode curNode,
- List<String> methods)
- throws IOException {
+ List<String> methods) {
//To string method.
List<YangType<?>> types = ((YangTypeDef) curNode).getTypeList();
diff --git a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
index a93a5cf..b0a7032 100644
--- a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
+++ b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
@@ -17,6 +17,7 @@
package org.onosproject.yangutils.translator.tojava.utils;
import org.onosproject.yangutils.datamodel.InvalidOpTypeHolder;
+import org.onosproject.yangutils.datamodel.RpcNotificationContainer;
import org.onosproject.yangutils.datamodel.YangAtomicPath;
import org.onosproject.yangutils.datamodel.YangCompilerAnnotation;
import org.onosproject.yangutils.datamodel.YangEnum;
@@ -1224,7 +1225,8 @@
* @return enum's constructor
*/
static String getEnumsConstructor(String className) {
- StringBuilder builder = new StringBuilder();
+ StringBuilder builder = new StringBuilder(
+ getJavaDoc(TYPE_CONSTRUCTOR, className, false, null));
String clsName = getSmallCase(className);
LinkedHashMap<String, String> map = new LinkedHashMap<>();
map.put(clsName, INT);
@@ -1861,15 +1863,19 @@
}
/**
- * Returns build method for augment class.
+ * Returns build method for subtree filtering in class.
*
- * @param name class name
- * @return build method for augment class
+ * @param node YANG node
+ * @return build method for subtree filtering in class
*/
- static String generateBuildMethodInAugmentClass(String name) {
+ static String generateBuildMethodForSubTree(YangNode node) {
+ String name = getCapitalCase(node.getJavaClassNameOrBuiltInType());
StringBuilder builder = new StringBuilder(getJavaDoc(BUILD_METHOD,
name, false, null));
String def = DEFAULT_CAPS + name;
+ if (node instanceof RpcNotificationContainer) {
+ def = name + OP_PARAM;
+ }
builder.append(methodSignature(BUILD_FOR_FILTER, null, PUBLIC, null,
name, null, CLASS_TYPE))
.append(EIGHT_SPACE_INDENTATION).append(SUBTREE_FILTERED)
diff --git a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/StringGenerator.java b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/StringGenerator.java
index f680b50..b901b62 100644
--- a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/StringGenerator.java
+++ b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/StringGenerator.java
@@ -302,7 +302,6 @@
String paramType, boolean isBuilderSetter, String setterVal) {
StringBuilder builder = new StringBuilder();
String body;
- String cond;
switch (type) {
case GETTER:
return getReturnString(paraName, space);
@@ -323,7 +322,7 @@
NEW + SPACE + paraName + getOpenCloseParaWithValue(
THIS) + signatureClose(), space);
case CONSTRUCTOR:
- return space + THIS + PERIOD + paraName + SPACE +
+ return space + paraName + SPACE +
EQUAL + SPACE + BUILDER_LOWER_CASE + OBJECT + PERIOD +
prefix + methodName +
brackets(OPEN_CLOSE_BRACKET, null, null) +
diff --git a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/SubtreeFilteringMethodsGenerator.java b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/SubtreeFilteringMethodsGenerator.java
index fb7b732..2a1b28f 100644
--- a/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/SubtreeFilteringMethodsGenerator.java
+++ b/generator/src/main/java/org/onosproject/yangutils/translator/tojava/utils/SubtreeFilteringMethodsGenerator.java
@@ -60,16 +60,15 @@
import static org.onosproject.yangutils.translator.tojava.utils.StringGenerator.methodClose;
import static org.onosproject.yangutils.translator.tojava.utils.StringGenerator.multiAttrMethodSignature;
import static org.onosproject.yangutils.translator.tojava.utils.StringGenerator.signatureClose;
-import static org.onosproject.yangutils.translator.tojava.utils.StringGenerator.valueAssign;
import static org.onosproject.yangutils.translator.tojava.utils.TranslatorUtils.getBeanFiles;
import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.AND_OPERATION;
import static org.onosproject.yangutils.utils.UtilConstants.APP_INSTANCE;
+import static org.onosproject.yangutils.utils.UtilConstants.BIT_SET;
import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE;
-import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_WRAPPER;
import static org.onosproject.yangutils.utils.UtilConstants.BREAK;
-import static org.onosproject.yangutils.utils.UtilConstants.BUILD;
import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
+import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_LOWER_CASE;
import static org.onosproject.yangutils.utils.UtilConstants.BUILD_FOR_FILTER;
import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
@@ -88,6 +87,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG;
import static org.onosproject.yangutils.utils.UtilConstants.IS_EMPTY;
import static org.onosproject.yangutils.utils.UtilConstants.IS_SELECT_ALL_SCHEMA_CHILD_FLAG;
+import static org.onosproject.yangutils.utils.UtilConstants.LEAF_IDENTIFIER;
import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.NOT;
import static org.onosproject.yangutils.utils.UtilConstants.NULL;
@@ -109,9 +109,11 @@
import static org.onosproject.yangutils.utils.UtilConstants.SELECT_LEAF;
import static org.onosproject.yangutils.utils.UtilConstants.SELECT_OR_CONTAINMENT_NODE_PARAM;
import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLON;
+import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX;
import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
import static org.onosproject.yangutils.utils.UtilConstants.STF_BUILDER_PARAM;
+import static org.onosproject.yangutils.utils.UtilConstants.SUBTREE_FILTERED;
import static org.onosproject.yangutils.utils.UtilConstants.SUBTREE_FILTERING_RESULT_BUILDER;
import static org.onosproject.yangutils.utils.UtilConstants.THIRTY_TWO_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.TO;
@@ -122,6 +124,8 @@
import static org.onosproject.yangutils.utils.UtilConstants.TWENTY_SPACE_INDENTATION;
import static org.onosproject.yangutils.utils.UtilConstants.TWO;
import static org.onosproject.yangutils.utils.UtilConstants.VALUE_LEAF;
+import static org.onosproject.yangutils.utils.UtilConstants.VALUE_LEAF_SET;
+import static org.onosproject.yangutils.utils.UtilConstants.ZERO;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
@@ -203,11 +207,28 @@
* isAnySelectOrContainmentNode = true;
* subTreeFilteringResultBuilder.leaf(appInstance.leaf());
* }*/
+
+/* if (isSubTreeFiltered && !appInstance.isLeafValueSet(
+ LeafIdentifier.LEAF2)) {
+ subTreeFilteringResultBuilder.leaf2(leaf2());
+ } else {
+ return false;
+ }*/
+ String condition = SUBTREE_FILTERED + SPACE + AND_OPERATION + SPACE + NOT +
+ APP_INSTANCE + PERIOD + VALUE_LEAF_SET +
+ getOpenCloseParaWithValue(
+ LEAF_IDENTIFIER + PERIOD + attributeName.toUpperCase());
return getIfConditionBegin(EIGHT_SPACE_INDENTATION, getLeafFlagSetString(
attributeName, VALUE_LEAF, EMPTY_STRING, GET)) +
getIfConditionBegin(TWELVE_SPACE_INDENTATION, attrQualifiedType) +
- getReturnString(FALSE, SIXTEEN_SPACE_INDENTATION) +
- signatureClose() +
+ getIfConditionBegin(SIXTEEN_SPACE_INDENTATION, condition) +
+ TWENTY_SPACE_INDENTATION + SUBTREE_FILTERING_RESULT_BUILDER +
+ PERIOD + attributeName + getOpenCloseParaWithValue(
+ attributeName + OPEN_CLOSE_BRACKET_STRING) + signatureClose() +
+ SIXTEEN_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + ELSE +
+ OPEN_CURLY_BRACKET + NEW_LINE + getReturnString(
+ FALSE, TWENTY_SPACE_INDENTATION) + signatureClose() +
+ SIXTEEN_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE +
TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + ELSE +
OPEN_CURLY_BRACKET + NEW_LINE +
getSubTreeBuilderCallString(SIXTEEN_SPACE_INDENTATION, attributeName,
@@ -215,8 +236,7 @@
getElseIfConditionBegin(EIGHT_SPACE_INDENTATION, getLeafFlagSetString(
attributeName, SELECT_LEAF, EMPTY_STRING, GET) + SPACE +
OR_OPERATION + SPACE + IS_SELECT_ALL_SCHEMA_CHILD_FLAG) +
- valueAssign(IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG, TRUE,
- TWELVE_SPACE_INDENTATION) +
+ getSelectOrContainmentAssignString() +
getSubTreeBuilderCallString(TWELVE_SPACE_INDENTATION, attributeName,
EIGHT_SPACE);
}
@@ -449,15 +469,14 @@
name = caseName;
}
- String javadoc = "\n /**\n" +
- " * Checks if the passed " + name +
- " maps the content match query condition.\n" +
+ String javadoc = "\n /**\n" +
+ " * Checks if the passed " + name + " maps the content " +
+ "match query condition.\n" +
" *\n" +
- " * @param " + instance + SPACE +
- instance + SPACE + "being passed to check" +
- " for" +
- " content match\n" +
- " * @param isSelectAllSchemaChild is select all schema child\n" +
+ " * @param " + instance + SPACE + instance + SPACE +
+ "being passed to check for content match\n" +
+ " * @param isSelectAllSchemaChild is select all schema " +
+ "child\n" +
" * @return match result\n" +
" */\n";
Map<String, String> param = new LinkedHashMap<>();
@@ -471,9 +490,9 @@
builder.append(getNewInstance(builderNamePrefix + BUILDER,
SUBTREE_FILTERING_RESULT_BUILDER,
EIGHT_SPACE_INDENTATION, EMPTY_STRING));
- builder.append(getNewInstance(BOOLEAN_WRAPPER,
+ builder.append(getNewInstance(BIT_SET,
IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG,
- EIGHT_SPACE_INDENTATION, FALSE));
+ EIGHT_SPACE_INDENTATION, EMPTY_STRING));
if (caseName != null) {
builder.append(getCaseCastString(javaFileInfo, instance, curNode));
}
@@ -494,7 +513,7 @@
private static String getProcessStfMethods(
String methodName, YangNode curNode, String path, int file)
throws IOException {
- StringBuilder builder = new StringBuilder();
+ StringBuilder builder = new StringBuilder(EMPTY_STRING);
JavaFileInfoTranslator javaFileInfo =
((JavaFileInfoContainer) curNode).getJavaFileInfo();
String instance = APP_INSTANCE;
@@ -509,8 +528,8 @@
Map<String, String> param = new LinkedHashMap<>();
param.put(instance, name);
param.put(STF_BUILDER_PARAM, builderNamePrefix + BUILDER);
- param.put(SELECT_OR_CONTAINMENT_NODE_PARAM, BOOLEAN_WRAPPER);
- param.put(SELECT_ALL_CHILD_SCHEMA_PARAM, BOOLEAN_WRAPPER);
+ param.put(SELECT_OR_CONTAINMENT_NODE_PARAM, BIT_SET);
+ param.put(SELECT_ALL_CHILD_SCHEMA_PARAM, BOOLEAN_DATA_TYPE);
builder.append(multiAttrMethodSignature(methodName, null,
PRIVATE, BOOLEAN_DATA_TYPE, param, CLASS_TYPE));
@@ -605,11 +624,10 @@
/**
* Returns is filter content match close.
*
- * @param name name of class
- * @param curNode current node
+ * @param name name of class
* @return is filter content match close
*/
- static String getProcessSubTreeFilteringEnd(String name, YangNode curNode) {
+ static String getProcessSubTreeFilteringEnd(String name) {
/* generate code will look like this.
if (!isSelectAllSchemaChild && !isAnySelectOrContainmentNode) {
return processSubtreeFiltering(appInstance, true);
@@ -619,19 +637,16 @@
StringBuilder builder = new StringBuilder();
String cond1 = NOT + IS_SELECT_ALL_SCHEMA_CHILD_FLAG + SPACE + AND_OPERATION +
- SPACE + NOT + IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG;
+ SPACE + NOT + IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG +
+ PERIOD + GET + getOpenCloseParaWithValue(ZERO);
String call = PROCESS_SUBTREE_FILTERING + getOpenCloseParaWithValue(
APP_INSTANCE + COMMA + SPACE + TRUE);
builder.append(getIfConditionBegin(EIGHT_SPACE_INDENTATION, cond1))
.append(getReturnString(call, TWELVE_SPACE_INDENTATION))
.append(signatureClose()).append(methodClose(EIGHT_SPACE));
- String build = BUILD;
- if (curNode instanceof YangAugment) {
- build = BUILD_FOR_FILTER;
- }
call = getOpenCloseParaWithValue(name) + SPACE +
- SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + build +
+ SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + BUILD_FOR_FILTER +
OPEN_CLOSE_BRACKET_STRING;
builder.append(getReturnString(call, EIGHT_SPACE_INDENTATION))
.append(signatureClose()).append(methodClose(FOUR_SPACE))
@@ -666,7 +681,8 @@
cast = name;
}
- String resultString = cast + PERIOD + PROCESS_SUBTREE_FILTERING + OPEN_PARENTHESIS
+ String resultString = cast + NEW_LINE + TWENTY_EIGHT_SPACE_INDENTATION +
+ PERIOD + PROCESS_SUBTREE_FILTERING + OPEN_PARENTHESIS
+ APP_INSTANCE + PERIOD + name + OPEN_CLOSE_BRACKET_STRING
+ COMMA + SPACE + FALSE + CLOSE_PARENTHESIS + SEMI_COLON +
NEW_LINE;
@@ -677,18 +693,20 @@
.append(getSelectOrContainmentAssignString());
builder.append(getIfConditionBegin(TWELVE_SPACE_INDENTATION,
- getAppInstanceCondition(name)));
+ getAppInstanceCondition(name, NOT)));
String assignment = SIXTEEN_SPACE_INDENTATION + clsInfo + SPACE + RESULT +
- signatureClose();
+ SPACE + EQUAL + SPACE + NULL + signatureClose();
builder.append(assignment)
.append(getIfConditionBegin(SIXTEEN_SPACE_INDENTATION,
SELECT_ALL_CHILD));
+/*
+ result = ((DefaultInterfaces)(DefaultInterfaces.builder()
+ .build())).processSubtreeFiltering(appInstance.interfaces(),
+ true);*/
- assignment = TWENTY_SPACE_INDENTATION + RESULT + SPACE + EQUAL + SPACE +
- getAppInstanceAttrString(name) + signatureClose();
-
+ assignment = getDummyObjectCreation(node, name, clsInfo, type, classCast, false);
builder.append(assignment).append(SIXTEEN_SPACE_INDENTATION).append(
CLOSE_CURLY_BRACKET).append(ELSE).append(OPEN_CURLY_BRACKET)
.append(NEW_LINE);
@@ -704,18 +722,20 @@
PERIOD + name + getOpenCloseParaWithValue(RESULT) +
signatureClose();
builder.append(assignment).append(methodClose(SIXTEEN_SPACE)).append(
- methodClose(TWELVE_SPACE)).append(methodClose(EIGHT_SPACE));
+ TWELVE_SPACE_INDENTATION).append(CLOSE_CURLY_BRACKET)
+ .append(getSubTreeFilteredCondition(name)).append(methodClose(EIGHT_SPACE));
return builder.toString();
}
- private static String getAppInstanceCondition(String name) {
+ private static String getAppInstanceCondition(String name, String condition) {
return APP_INSTANCE + PERIOD + name + OPEN_CLOSE_BRACKET_STRING + SPACE +
- NOT + EQUAL + SPACE + NULL;
+ condition + EQUAL + SPACE + NULL;
}
private static String getSelectOrContainmentAssignString() {
return TWELVE_SPACE_INDENTATION + IS_ANY_SELECT_OR_CONTAINMENT_NODE_FLAG +
- SPACE + EQUAL + SPACE + TRUE + signatureClose();
+ PERIOD + SET_METHOD_PREFIX + getOpenCloseParaWithValue(ZERO) +
+ signatureClose();
}
/**
@@ -747,8 +767,8 @@
if (node != null && node instanceof YangChoice) {
cast = name;
}
- String resultString = cast + PERIOD +
- PROCESS_SUBTREE_FILTERING + OPEN_PARENTHESIS +
+ String resultString = cast + NEW_LINE + TWENTY_EIGHT_SPACE_INDENTATION +
+ PERIOD + PROCESS_SUBTREE_FILTERING + OPEN_PARENTHESIS +
name + "2" + COMMA + SPACE + FALSE + CLOSE_PARENTHESIS + SEMI_COLON +
NEW_LINE;
/*
@@ -756,14 +776,38 @@
*/
builder.append(getIfConditionBegin(EIGHT_SPACE_INDENTATION,
IS_SELECT_ALL_SCHEMA_CHILD_FLAG))
- .append(getForLoopString(TWELVE_SPACE_INDENTATION, type, name,
+ .append(getIfConditionBegin(TWELVE_SPACE_INDENTATION,
+ getAppInstanceCondition(name, NOT)))
+ .append(getForLoopString(SIXTEEN_SPACE_INDENTATION, type, name,
getAppInstanceAttrString(name)));
+ String assignment;
+ if (!isLeafList) {
+ builder.append(TWENTY_SPACE_INDENTATION).append(type).append(SPACE)
+ .append(RESULT).append(signatureClose());
+ assignment = getDummyObjectCreation(node, name, type, clsInfo,
+ classCast, true);
+ builder.append(assignment);
+ assignment = TWENTY_SPACE_INDENTATION +
+ SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + ADD_STRING +
+ getCapitalCase(TO) + caps + getOpenCloseParaWithValue(RESULT) +
+ signatureClose();
+ builder.append(assignment);
+ } else {
+ assignment = TWENTY_SPACE_INDENTATION +
+ SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + ADD_STRING +
+ getCapitalCase(TO) + caps + getOpenCloseParaWithValue(name) +
+ signatureClose();
+ builder.append(assignment);
+ }
+ builder.append(methodClose(SIXTEEN_SPACE))
+ .append(TWELVE_SPACE_INDENTATION).append(CLOSE_CURLY_BRACKET);
- String assignment = SIXTEEN_SPACE_INDENTATION +
- SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + ADD_STRING +
- getCapitalCase(TO) + caps + getOpenCloseParaWithValue(name) +
- signatureClose();
- builder.append(assignment).append(methodClose(TWELVE_SPACE));
+/* } else {
+ if (isSubTreeFiltered && leafList2() != null) {
+ subTreeFilteringResultBuilder.addToLeafList2(leafList2());
+ }
+ }*/
+ builder.append(getSubTreeFilteredCondition(name));
String cond = name + OPEN_CLOSE_BRACKET_STRING + SPACE + NOT + EQUAL +
SPACE + NULL;
@@ -780,9 +824,9 @@
builder.append(getIfConditionBegin(TWELVE_SPACE_INDENTATION, cond));
if (isLeafList) {
- cond = getAppInstanceCondition(name) + SPACE + OR_OPERATION + SPACE +
- APP_INSTANCE + PERIOD + name + OPEN_CLOSE_BRACKET_STRING +
- PERIOD + IS_EMPTY;
+ cond = getAppInstanceCondition(name, EQUAL) + SPACE + OR_OPERATION +
+ SPACE + APP_INSTANCE + PERIOD + name +
+ OPEN_CLOSE_BRACKET_STRING + PERIOD + IS_EMPTY;
/*
* If there is no app instance to perform content match
*/
@@ -829,8 +873,8 @@
.append(methodClose(SIXTEEN_SPACE)); // for instance iterator
} else {
- cond = getAppInstanceCondition(name) + SPACE + AND_OPERATION +
- SPACE + getAppInstanceAttrString(name) +
+ cond = getAppInstanceCondition(name, NOT) + SPACE + AND_OPERATION +
+ SPACE + NOT + getAppInstanceAttrString(name) +
PERIOD + IS_EMPTY;
/*if there is any app instance entry*/
builder.append(getIfConditionBegin(SIXTEEN_SPACE_INDENTATION,
@@ -852,13 +896,14 @@
assignment = THIRTY_TWO_SPACE_INDENTATION +
SUBTREE_FILTERING_RESULT_BUILDER + PERIOD + ADD_STRING +
getCapitalCase(TO) + caps + getOpenCloseParaWithValue(
- name) + signatureClose();
+ RESULT) + signatureClose();
builder.append(assignment).append(methodClose(TWENTY_EIGHT_SPACE))
//loop all the app instance(s)
.append(methodClose(TWENTY_FOUR_SPACE))
//loop all the query condition instance(s)
.append(methodClose(TWENTY_SPACE))
- .append(methodClose(SIXTEEN_SPACE));
+ .append(SIXTEEN_SPACE_INDENTATION).append(CLOSE_CURLY_BRACKET)
+ .append(getSubTreeFilteredCondition(name));
//if there is any app instance entry
}
@@ -869,7 +914,7 @@
if (isLeafList) {
builder.append(getSelectOrContainmentAssignString());
}
- cond = getAppInstanceCondition(name) + SPACE + AND_OPERATION +
+ cond = getAppInstanceCondition(name, NOT) + SPACE + AND_OPERATION +
SPACE + NOT + getAppInstanceAttrString(name) + PERIOD + IS_EMPTY;
builder.append(getIfConditionBegin(SIXTEEN_SPACE_INDENTATION, cond))
.append(getForLoopString(SIXTEEN_SPACE_INDENTATION, type,
@@ -889,7 +934,7 @@
//Returns method string for op params augmented syntax
static String getAugmentableSubTreeFiltering() {
- return " for (Object augmentInfo : this.yangAugmentedInfoMap()" +
+ return " for (Object augmentInfo : yangAugmentedInfoMap()" +
".values()) {\n" +
" Object appInstanceInfo = appInstance.yangAugmentedInfo(" +
"augmentInfo.getClass());\n" +
@@ -916,6 +961,22 @@
" }\n";
}
+ private static String getSubTreeFilteredCondition(String name) {
+ StringBuilder builder = new StringBuilder();
+ String cond = SUBTREE_FILTERED + SPACE + AND_OPERATION + SPACE + name +
+ OPEN_CLOSE_BRACKET_STRING + SPACE + NOT + EQUAL + SPACE + NULL;
+
+ builder.append(ELSE).append(OPEN_CURLY_BRACKET).append(NEW_LINE)
+ .append(getIfConditionBegin(SIXTEEN_SPACE_INDENTATION, cond))
+ .append(TWENTY_SPACE_INDENTATION)
+ .append(SUBTREE_FILTERING_RESULT_BUILDER).append(PERIOD)
+ .append(name).append(getOpenCloseParaWithValue(name)).append(
+ signatureClose()).append(SIXTEEN_SPACE_INDENTATION).append(
+ CLOSE_CURLY_BRACKET).append(NEW_LINE).append(TWELVE_SPACE_INDENTATION)
+ .append(CLOSE_CURLY_BRACKET).append(NEW_LINE);
+ return builder.toString();
+ }
+
private static String getNameOfClassForIfCase(YangNode curNode) {
String name = null;
JavaFileInfoTranslator parentInfo;
@@ -951,4 +1012,47 @@
return null;
}
+ private static String getDummyObjectCreation(YangNode node, String name,
+ String clsInfo, String type,
+ String classCast, boolean isList) {
+ String para = getAppInstanceAttrString(name);
+ if (isList) {
+ para = name;
+ }
+ if (node != null && node instanceof YangChoice) {
+ return getChoiceReflectionResult(name, clsInfo);
+ }
+ return TWENTY_SPACE_INDENTATION + RESULT + SPACE + EQUAL + SPACE +
+ getOpenCloseParaWithValue(
+ classCast + type + PERIOD + BUILDER_LOWER_CASE +
+ OPEN_CLOSE_BRACKET_STRING + NEW_LINE +
+ TWENTY_EIGHT_SPACE_INDENTATION + PERIOD +
+ BUILD_FOR_FILTER + OPEN_CLOSE_BRACKET_STRING) +
+ PERIOD + PROCESS_SUBTREE_FILTERING + getOpenCloseParaWithValue(
+ para + COMMA + SPACE + TRUE) + signatureClose();
+
+ }
+
+ private static String getChoiceReflectionResult(String name, String returnType) {
+ String call = "appInstance." + name + "()";
+ return " Class<?>[] classArray = " + call + "" +
+ ".getClass()" +
+ ".getInterfaces();\n" +
+ " Class<?> caseClass = classArray[0];\n" +
+ " try {\n" +
+ " Object obj1 = caseClass.newInstance();\n" +
+ " Method method = caseClass.getMethod(\"builder\", caseClass);\n" +
+ " Object obj = method.invoke(obj1," +
+ " (Object) null);\n" +
+ " method = caseClass.getMethod(\"build\", caseClass);\n" +
+ " Object obj2 = method.invoke(obj, " +
+ "(Object) null);\n" +
+ " method = caseClass.getMethod(\"processSubtreeFiltering\", caseClass);\n" +
+ " result = (" + returnType + ") method.invoke" +
+ "(obj2, " + call + ", true);\n" +
+ " } catch (NoSuchMethodException | InstantiationException |\n" +
+ " IllegalAccessException | InvocationTargetException e) {\n" +
+ " e.printStackTrace();\n" +
+ " }\n";
+ }
}
diff --git a/generator/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java b/generator/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
index 8266eca..3a1a1f5 100644
--- a/generator/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
+++ b/generator/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
@@ -167,11 +167,6 @@
public static final String JAVA_DOC_BUILD = " * Builds object of ";
/**
- * JavaDocs's return statement for build method.
- */
- public static final String JAVA_DOC_BUILD_RETURN = "object of ";
-
- /**
* JavaDocs's statement for builder object.
*/
public static final String BUILDER_OBJECT = "builder object of ";
@@ -238,11 +233,6 @@
public static final String COMPARE_TO = "compareTo";
/**
- * Static attribute for period.
- */
- public static final String INVOKE = "invoke";
-
- /**
* Static attribute for parse byte.
*/
public static final String PARSE_BYTE = "parseByte";
@@ -340,11 +330,6 @@
public static final String SCHEMA_NAME = "schemaName";
/**
- * Static attribute for schema name value.
- */
- public static final String STR_VAL = "stringValue";
-
- /**
* Static attribute for validateRange.
*/
public static final String VALIDATE_RANGE = "validateRange";
@@ -506,11 +491,6 @@
public static final String SUBJECT = "Subject";
/**
- * Static attribute for ListenerRegistry.
- */
- public static final String LISTENER_REG = "ListenerRegistry";
-
- /**
* Static attribute for ListenerService.
*/
public static final String LISTENER_SERVICE = "ListenerService";
@@ -551,11 +531,6 @@
public static final String LEAFREF = "leafref";
/**
- * Static attribute for identityref string.
- */
- public static final String IDENTITYREF = "identityref";
-
- /**
* Static attribute for output variable of rpc.
*/
public static final String RPC_INPUT_VAR_NAME = "inputVar";
@@ -576,11 +551,6 @@
public static final String ADD = "+";
/**
- * Static attribute for single quote.
- */
- public static final String SINGLE_QUOTE = "\'";
-
- /**
* Static attribute for quotes.
*/
public static final String QUOTES = "\"";
@@ -626,11 +596,6 @@
public static final char CHAR_OF_OPEN_SQUARE_BRACKET = '[';
/**
- * Static attribute for close square bracket character.
- */
- public static final char CHAR_OF_CLOSE_SQUARE_BRACKET = ']';
-
- /**
* Static attribute for slash string.
*/
public static final String SLASH_FOR_STRING = "/";
@@ -656,11 +621,6 @@
public static final String ADD_STRING = "add";
/**
- * Static attribute for string replace syntax.
- */
- public static final String REPLACE_STRING = "replace";
-
- /**
* Static attribute for string trim syntax.
*/
public static final String TRIM_STRING = "trim";
@@ -735,11 +695,6 @@
public static final String IF = "if";
/**
- * Static attribute for else-if.
- */
- public static final String ELSE_IF = "else if";
-
- /**
* Static attribute for of.
*/
public static final String OF = "of";
@@ -889,37 +844,11 @@
public static final String GET_METHOD_PREFIX = "get";
/**
- * Static attribute for getter method prefix.
- */
- public static final String GET_METHOD = "getMethod";
-
- /**
- * Static attribute for getter method prefix.
- */
- public static final String GET_CLASS = "getClass()";
-
- /**
* Static attribute for setter method prefix.
*/
public static final String SET_METHOD_PREFIX = "set";
/**
- * Static attribute for get filter leaf flags.
- */
- public static final String GET_VALUE_LEAF_FLAGS = "getValueLeafFlags";
-
- /**
- * Static attribute for get select filter leaf flags.
- */
- public static final String GET_SELECT_LEAF_FLAGS = "getSelectLeafFlags";
-
-
- /**
- * Static attribute for getLeafIndex.
- */
- public static final String GET_LEAF_INDEX = "getLeafIndex()";
-
- /**
* Static attribute for op param.
*/
public static final String OP_PARAM = "OpParam";
@@ -1066,11 +995,6 @@
TWENTY_EIGHT_SPACE_INDENTATION + FOUR_SPACE_INDENTATION;
/**
- * continue.
- */
- public static final String CONTINUE = "continue";
-
- /**
* Static attribute for generated code path.
*/
public static final String YANG_GEN_DIR = "src/main/java/";
@@ -1335,11 +1259,6 @@
public static final String BUILDER_LOWER_CASE = "builder";
/**
- * Static attribute for manager syntax.
- */
- public static final String MANAGER = "Manager";
-
- /**
* Static attribute for service syntax.
*/
public static final String SERVICE = "Service";
@@ -1470,9 +1389,9 @@
public static final String COLLECTION_IMPORTS = "java.util";
/**
- * Static attribute for regex.
+ * Static attribute for reflect.
*/
- public static final String REGEX_IMPORTS = "java.util.regex";
+ public static final String REFLECT_IMPORTS = "java.lang.reflect";
/**
* Static attribute for map.
@@ -1531,9 +1450,9 @@
public static final String SET_VALUE_PARA = "setValue";
/**
- * Static attribute for java utilities import package.
+ * Static attribute for Method.
*/
- public static final String HELPER = "helper";
+ public static final String METHOD = "Method";
/**
* Static attribute for bitset.
@@ -1583,7 +1502,7 @@
public static final String SET = "Set";
/**
- * Comment to be added for autogenerated impl methods.
+ * Comment to be added for auto generated impl methods.
*/
public static final String YANG_UTILS_TODO =
"//TODO: YANG utils generated code";
@@ -1749,18 +1668,6 @@
public static final String FOR = "for";
/**
- * Static attribute for YangAugmentedOpParamInfo.
- */
- public static final String YANG_AUGMENTED_OP_PARAM_INFO =
- "YangAugmentedOpParamInfo";
-
- /**
- * Static attribute for NoSuchMethodException.
- */
- public static final String NO_SUCH_METHOD_EXCEPTION =
- "NoSuchMethodException";
-
- /**
* Static attribute for InvocationTargetException.
*/
public static final String INVOCATION_TARGET_EXCEPTION =
@@ -1771,11 +1678,6 @@
*/
public static final String INVOCATION_TARGET_EXCEPTION_IMPORT = "import" +
" java.lang.reflect.InvocationTargetException;\n";
- /**
- * Static attribute for IllegalAccessException.
- */
- public static final String ILLEGAL_ACCESS_EXCEPTION =
- "IllegalAccessException";
/**
* Static attribute for arrayList.
@@ -1861,21 +1763,11 @@
public static final String BUILDER_INTERFACE = "builder interface";
/**
- * Static attribute for binary.
- */
- public static final String BINARY = "binary";
-
- /**
* Static attribute for bits.
*/
public static final String BITS = "bits";
/**
- * Static attribute for bits.
- */
- public static final String BITS_CAPS = "Bits";
-
- /**
* Static attribute for YANG.
*/
public static final String YANG = "yang";
@@ -1951,11 +1843,6 @@
public static final String SELECT_ALL_CHILD_SCHEMA_PARAM =
"isSelectAllSchemaChild";
- /**
- * Static param for ResultOfProcessSubTree.
- */
- public static final String CHOICE_STF_METHOD_NAME =
- "ResultOfProcessSubTree";
//File type extension for java classes.
public static final String JAVA_FILE_EXTENSION = ".java";
diff --git a/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java b/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
index 02389a1..fb76dff 100644
--- a/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
+++ b/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
@@ -16,22 +16,31 @@
package org.onosproject.yangutils.parser.impl.listeners;
-import org.onosproject.yangutils.datamodel.ResolvableType;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangReferenceResolver;
+import org.onosproject.yangutils.datamodel.YangResolutionInfo;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.datamodel.utils.Parsable;
import org.onosproject.yangutils.linker.exceptions.LinkerException;
-import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
+import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
+import java.util.List;
+
+import static org.onosproject.yangutils.datamodel.ResolvableType.YANG_BASE;
+import static org.onosproject.yangutils.datamodel.ResolvableType.YANG_COMPILER_ANNOTATION;
+import static org.onosproject.yangutils.datamodel.ResolvableType.YANG_DERIVED_DATA_TYPE;
+import static org.onosproject.yangutils.datamodel.ResolvableType.YANG_IDENTITYREF;
+import static org.onosproject.yangutils.datamodel.ResolvableType.YANG_IF_FEATURE;
+import static org.onosproject.yangutils.datamodel.ResolvableType.YANG_LEAFREF;
+import static org.onosproject.yangutils.datamodel.ResolvableType.YANG_USES;
import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
import static org.onosproject.yangutils.datamodel.utils.YangConstructType.MODULE_DATA;
+import static org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser.ModuleStatementContext;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
- .constructListenerErrorMessage;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CHILD;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
@@ -78,13 +87,14 @@
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
- public static void processModuleEntry(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
+ public static void processModuleEntry(TreeWalkListener listener,
+ ModuleStatementContext ctx) {
// Check if stack is empty.
- checkStackIsEmpty(listener, INVALID_HOLDER, MODULE_DATA, ctx.identifier().getText(), ENTRY);
-
- String identifier = getValidIdentifier(ctx.identifier().getText(), MODULE_DATA, ctx);
-
+ checkStackIsEmpty(listener, INVALID_HOLDER, MODULE_DATA,
+ ctx.identifier().getText(), ENTRY);
+ String identifier = getValidIdentifier(ctx.identifier().getText(),
+ MODULE_DATA, ctx);
YangModule yangModule = getYangModuleNode(JAVA_GENERATION);
yangModule.setName(identifier);
yangModule.setLineNumber(ctx.getStart().getLine());
@@ -105,38 +115,32 @@
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
- public static void processModuleExit(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
+ public static void processModuleExit(TreeWalkListener listener,
+ ModuleStatementContext ctx) {
// Check for stack to be non empty.
- checkStackIsNotEmpty(listener, MISSING_HOLDER, MODULE_DATA, ctx.identifier().getText(), EXIT);
-
+ checkStackIsNotEmpty(listener, MISSING_HOLDER, MODULE_DATA,
+ ctx.identifier().getText(), EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
if (!(tmpNode instanceof YangModule)) {
- throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, MODULE_DATA,
- ctx.identifier().getText(), EXIT));
+ throwError(MISSING_CURRENT_HOLDER, ctx);
}
YangModule module = (YangModule) tmpNode;
- if (module.getUnresolvedResolutionList(ResolvableType.YANG_COMPILER_ANNOTATION) != null
- && module.getUnresolvedResolutionList(ResolvableType.YANG_COMPILER_ANNOTATION).size() != 0
- && module.getChild() != null) {
- throw new ParserException(constructListenerErrorMessage(INVALID_CHILD, MODULE_DATA,
- ctx.identifier().getText(), EXIT));
+ List<YangResolutionInfo> info = module.getUnresolvedResolutionList(
+ YANG_COMPILER_ANNOTATION);
+ if (info != null && !info.isEmpty() && module.getChild() != null) {
+ throwError(INVALID_CHILD, ctx);
}
-
+ YangReferenceResolver resolver = (YangReferenceResolver) listener
+ .getParsedDataStack().peek();
try {
- ((YangReferenceResolver) listener.getParsedDataStack()
- .peek()).resolveSelfFileLinking(ResolvableType.YANG_IF_FEATURE);
- ((YangReferenceResolver) listener.getParsedDataStack()
- .peek()).resolveSelfFileLinking(ResolvableType.YANG_USES);
- ((YangReferenceResolver) listener.getParsedDataStack()
- .peek()).resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
- ((YangReferenceResolver) listener.getParsedDataStack()
- .peek()).resolveSelfFileLinking(ResolvableType.YANG_LEAFREF);
- ((YangReferenceResolver) listener.getParsedDataStack()
- .peek()).resolveSelfFileLinking(ResolvableType.YANG_BASE);
- ((YangReferenceResolver) listener.getParsedDataStack()
- .peek()).resolveSelfFileLinking(ResolvableType.YANG_IDENTITYREF);
+ resolver.resolveSelfFileLinking(YANG_IF_FEATURE);
+ resolver.resolveSelfFileLinking(YANG_USES);
+ resolver.resolveSelfFileLinking(YANG_DERIVED_DATA_TYPE);
+ resolver.resolveSelfFileLinking(YANG_LEAFREF);
+ resolver.resolveSelfFileLinking(YANG_BASE);
+ resolver.resolveSelfFileLinking(YANG_IDENTITYREF);
} catch (DataModelException e) {
LinkerException linkerException = new LinkerException(e.getMessage());
linkerException.setLine(e.getLineNumber());
@@ -145,4 +149,10 @@
throw linkerException;
}
}
+
+ private static void throwError(ListenerErrorType type,
+ ModuleStatementContext ctx) {
+ throw new ParserException(constructListenerErrorMessage(
+ type, MODULE_DATA, ctx.identifier().getText(), EXIT));
+ }
}
diff --git a/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java b/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
index 88def1d..bf69035 100644
--- a/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
+++ b/parser/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
@@ -99,7 +99,7 @@
// Create YANG type object and fill the values.
YangType<?> type = getYangType(JAVA_GENERATION);
- type.setNodeIdentifier(nodeIdentifier);
+ type.setNodeId(nodeIdentifier);
type.setDataType(yangDataTypes);
type.setLineNumber(ctx.getStart().getLine());
diff --git a/parser/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerCollisionDetector.java b/parser/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerCollisionDetector.java
index 632f50d..55b9e01 100644
--- a/parser/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerCollisionDetector.java
+++ b/parser/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerCollisionDetector.java
@@ -55,9 +55,10 @@
String identifierName, YangConstructType constructType)
throws ParserException {
- if (listener.getParsedDataStack().peek() instanceof CollisionDetector) {
+ Object obj = listener.getParsedDataStack().peek();
+ if (obj instanceof CollisionDetector) {
try {
- ((CollisionDetector) listener.getParsedDataStack().peek()).detectCollidingChild(
+ ((CollisionDetector) obj).detectCollidingChild(
identifierName, constructType);
} catch (DataModelException e) {
ParserException parserException = new ParserException(e.getMessage());
diff --git a/plugin/maven/src/main/java/org/onosproject/yangutils/plugin/manager/YangPluginUtils.java b/plugin/maven/src/main/java/org/onosproject/yangutils/plugin/manager/YangPluginUtils.java
index 00331b2..9f461b6 100644
--- a/plugin/maven/src/main/java/org/onosproject/yangutils/plugin/manager/YangPluginUtils.java
+++ b/plugin/maven/src/main/java/org/onosproject/yangutils/plugin/manager/YangPluginUtils.java
@@ -18,18 +18,18 @@
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Plugin;
import org.apache.maven.model.Resource;
import org.apache.maven.project.MavenProject;
import org.onosproject.yangutils.datamodel.YangNode;
import org.slf4j.Logger;
import org.sonatype.plexus.build.incremental.BuildContext;
+import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.io.ObjectOutputStream;
-import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
@@ -39,8 +39,6 @@
import java.util.Set;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.parseJarFile;
-import static org.onosproject.yangutils.utils.UtilConstants.COLON;
-import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN;
import static org.onosproject.yangutils.utils.UtilConstants.JAR;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
@@ -56,14 +54,10 @@
public final class YangPluginUtils {
private static final Logger log = getLogger(YangPluginUtils.class);
-
- private static final String TARGET_RESOURCE_PATH = SLASH + TEMP + SLASH + YANG_RESOURCES + SLASH;
-
+ private static final String TARGET_RESOURCE_PATH = SLASH + TEMP + SLASH +
+ YANG_RESOURCES + SLASH;
private static final String SERIALIZED_FILE_EXTENSION = ".ser";
- private static final String TEXT_FILE_EXTENSION = ".txt";
private static final String YANG_META_DATA = "YangMetaData";
- private static final String VERSION_META_DATA = "VersionMetaData";
- private static final String PLUGIN_ARTIFACT = "onos-yang-maven-plugin";
private YangPluginUtils() {
}
@@ -75,7 +69,8 @@
* @param project current maven project
* @param context current build context
*/
- static void addToCompilationRoot(String source, MavenProject project, BuildContext context) {
+ static void addToCompilationRoot(String source, MavenProject project,
+ BuildContext context) {
project.addCompileSourceRoot(source);
context.refresh(project.getBasedir());
log.info("Source directory added to compilation root: " + source);
@@ -89,15 +84,14 @@
* @param project maven project
* @throws IOException when fails to copy files to destination resource directory
*/
- static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project)
+ static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo,
+ String outputDir, MavenProject project)
throws IOException {
List<File> files = getListOfFile(yangFileInfo);
-
String path = outputDir + TARGET_RESOURCE_PATH;
File targetDir = new File(path);
targetDir.mkdirs();
-
for (File file : files) {
Files.copy(file.toPath(),
new File(path + file.getName()).toPath(),
@@ -127,93 +121,58 @@
/**
* Serializes data-model.
*
- * @param directory base directory for serialized files
- * @param fileInfoSet YANG file info set
- * @param project maven project
- * @param operation true if need to add to resource
+ * @param dir base directory for serialized files
+ * @param fileSet YANG file info set
+ * @param project maven project
+ * @param operation true if need to add to resource
* @throws IOException when fails to do IO operations
*/
- public static void serializeDataModel(String directory, Set<YangFileInfo> fileInfoSet,
- MavenProject project, boolean operation) throws IOException {
-
- String serFileDirPath = directory + TARGET_RESOURCE_PATH;
- File dir = new File(serFileDirPath);
- dir.mkdirs();
-
+ public static void serializeDataModel(String dir, Set<YangFileInfo> fileSet,
+ MavenProject project, boolean operation)
+ throws IOException {
+ String serFileDirPath = dir + TARGET_RESOURCE_PATH;
+ File dir1 = new File(serFileDirPath);
+ dir1.mkdirs();
if (operation) {
- addToProjectResource(directory + SLASH + TEMP + SLASH, project);
+ addToProjectResource(dir + SLASH + TEMP + SLASH, project);
}
-
Set<YangNode> nodes = new HashSet<>();
- for (YangFileInfo fileInfo : fileInfoSet) {
+ for (YangFileInfo fileInfo : fileSet) {
nodes.add(fileInfo.getRootNode());
}
- String serFileName = serFileDirPath + YANG_META_DATA + SERIALIZED_FILE_EXTENSION;
- FileOutputStream fileOutputStream = new FileOutputStream(serFileName);
- ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
+ String serFileName = serFileDirPath + YANG_META_DATA +
+ SERIALIZED_FILE_EXTENSION;
+ FileOutputStream out = new FileOutputStream(serFileName);
+ ObjectOutputStream objectOutputStream = new ObjectOutputStream(out);
objectOutputStream.writeObject(nodes);
objectOutputStream.close();
- fileOutputStream.close();
- if (operation) {
- addVersionMetaDataFile(project, serFileDirPath);
- }
- }
-
- /**
- * Adds version meta data files for YSR to know version of YANG tools.
- *
- * @param project maven project
- * @param dir directory
- * @throws IOException when fails to do IO operations
- */
- private static void addVersionMetaDataFile(MavenProject project, String dir)
- throws IOException {
- List<Plugin> plugins = project.getBuildPlugins();
- Iterator<Plugin> it = plugins.iterator();
- Plugin plugin = it.next();
- String data = EMPTY_STRING;
- while (it.hasNext()) {
- if (plugin.getArtifactId().equals(PLUGIN_ARTIFACT)) {
- data = plugin.getGroupId() + COLON + plugin.getArtifactId()
- + COLON + plugin.getVersion();
- }
- plugin = it.next();
- }
- if (data.equals(EMPTY_STRING)) {
- throw new IOException("Invalid artifact for " + PLUGIN_ARTIFACT);
- }
- String verFileName = dir + VERSION_META_DATA + TEXT_FILE_EXTENSION;
- PrintWriter out = new PrintWriter(verFileName);
- out.print(data);
out.close();
}
/**
* Returns list of jar path.
*
- * @param project maven project
- * @param localRepository local repository
- * @param remoteRepos remote repository
+ * @param project maven project
+ * @param localRepo local repository
+ * @param remoteRepos remote repository
* @return list of jar paths
*/
- private static List<String> resolveDependencyJarPath(MavenProject project, ArtifactRepository localRepository,
- List<ArtifactRepository> remoteRepos) {
+ private static List<String> resolveDependencyJarPath(
+ MavenProject project, ArtifactRepository localRepo,
+ List<ArtifactRepository> remoteRepos) {
StringBuilder path = new StringBuilder();
List<String> jarPaths = new ArrayList<>();
for (Object obj : project.getDependencies()) {
Dependency dependency = (Dependency) obj;
- path.append(localRepository.getBasedir());
- path.append(SLASH);
- path.append(getPackageDirPathFromJavaJPackage(dependency.getGroupId()));
- path.append(SLASH);
- path.append(dependency.getArtifactId());
- path.append(SLASH);
- path.append(dependency.getVersion());
- path.append(SLASH);
- path.append(dependency.getArtifactId() + HYPHEN + dependency.getVersion() + PERIOD + JAR);
+ path.append(localRepo.getBasedir()).append(SLASH)
+ .append(getPackageDirPathFromJavaJPackage(dependency.getGroupId()))
+ .append(SLASH).append(dependency.getArtifactId())
+ .append(SLASH).append(dependency.getVersion()).append(SLASH)
+ .append(dependency.getArtifactId()).append(HYPHEN)
+ .append(dependency.getVersion()).append(PERIOD).append(JAR);
File jarFile = new File(path.toString());
if (jarFile.exists()) {
jarPaths.add(path.toString());
@@ -230,21 +189,23 @@
/**
* Resolves inter jar dependencies.
*
- * @param project current maven project
- * @param localRepository local maven repository
- * @param remoteRepos list of remote repository
- * @param directory directory for serialized files
+ * @param project current maven project
+ * @param localRepo local maven repository
+ * @param remoteRepos list of remote repository
+ * @param dir directory for serialized files
* @return list of resolved datamodel nodes
* @throws IOException when fails to do IO operations
*/
- static List<YangNode> resolveInterJarDependencies(MavenProject project, ArtifactRepository localRepository,
- List<ArtifactRepository> remoteRepos, String directory)
+ static List<YangNode> resolveInterJarDependencies(
+ MavenProject project, ArtifactRepository localRepo,
+ List<ArtifactRepository> remoteRepos, String dir)
throws IOException {
- List<String> dependenciesJarPaths = resolveDependencyJarPath(project, localRepository, remoteRepos);
+ List<String> dependenciesJarPaths =
+ resolveDependencyJarPath(project, localRepo, remoteRepos);
List<YangNode> resolvedDataModelNodes = new ArrayList<>();
for (String dependency : dependenciesJarPaths) {
- resolvedDataModelNodes.addAll(parseJarFile(dependency, directory));
+ resolvedDataModelNodes.addAll(parseJarFile(dependency, dir));
}
return resolvedDataModelNodes;
}
diff --git a/plugin/maven/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java b/plugin/maven/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java
index c56d8aa..ba0f6fd 100644
--- a/plugin/maven/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java
+++ b/plugin/maven/src/main/java/org/onosproject/yangutils/plugin/manager/YangUtilManager.java
@@ -78,8 +78,7 @@
*/
@Mojo(name = "yang2java", defaultPhase = PROCESS_SOURCES,
requiresDependencyResolution = COMPILE)
-public class YangUtilManager
- extends AbstractMojo {
+public class YangUtilManager extends AbstractMojo {
private static final String DEFAULT_PKG =
getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG);
@@ -278,7 +277,7 @@
*
* @return YANG node set
*/
- Set<YangNode> getYangNodeSet() {
+ public Set<YangNode> getYangNodeSet() {
return yangNodeSet;
}
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java
index c4a2341..531a285 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/AugmentTranslatorTest.java
@@ -57,7 +57,7 @@
yangPluginConfig.setCodeGenDir(DIR);
utilManager.translateToJava(yangPluginConfig);
compileCode(COMP);
- //deleteDirectory(DIR);
+ deleteDirectory(DIR);
}
/**
@@ -113,8 +113,6 @@
@Test
public void processChoiceAugmentInterTranslator() throws IOException,
ParserException, MojoExecutionException {
- //FIXME: for augment having node with child nodes.
- /*
deleteDirectory(DIR);
String searchDir = "src/test/resources/choiceAugment";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
@@ -127,7 +125,6 @@
utilManager.translateToJava(yangPluginConfig);
compileCode(COMP);
deleteDirectory(DIR);
- */
}
}
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/ChoiceCaseTranslatorTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/ChoiceCaseTranslatorTest.java
index 662b7e5..367bf82 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/ChoiceCaseTranslatorTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/ChoiceCaseTranslatorTest.java
@@ -16,11 +16,13 @@
package org.onosproject.yangutils.plugin.manager;
+import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import org.onosproject.yangutils.utils.io.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
import java.io.File;
import java.io.IOException;
@@ -33,7 +35,10 @@
* Unit tests for choice-case translator.
*/
public final class ChoiceCaseTranslatorTest {
-
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private static final String DIR = "target/ChoiceCaseTestGenFile/";
+ private static final String COMP = System.getProperty("user.dir") + File
+ .separator + DIR;
private final YangUtilsParserManager manager = new YangUtilsParserManager();
/**
@@ -54,5 +59,26 @@
compileCode(dir1);
deleteDirectory(dir);
}
- // TODO enhance the test cases, after having a framework of translator test.
+
+ /**
+ * Checks augment translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processChoiceAllTranslator() throws IOException,
+ ParserException, MojoExecutionException {
+ deleteDirectory(DIR);
+ String searchDir = "src/test/resources/choiceTranslator";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ compileCode(COMP);
+ deleteDirectory(DIR);
+ }
}
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/GroupingTranslatorTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/GroupingTranslatorTest.java
new file mode 100644
index 0000000..a590cc0
--- /dev/null
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/GroupingTranslatorTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.plugin.manager;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.utils.io.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.onosproject.yangutils.utils.io.YangPluginConfig.compileCode;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+
+/**
+ * Unit test case for grouping translator.
+ */
+public class GroupingTranslatorTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private static final String DIR = "target/groupingTranslator/";
+ private static final String COMP = System.getProperty("user.dir") + File
+ .separator + DIR;
+
+ /**
+ * Checks grouping translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processTranslator() throws IOException, ParserException, MojoExecutionException {
+
+ deleteDirectory(DIR);
+ String searchDir = "src/test/resources/grouping";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ compileCode(COMP);
+ deleteDirectory(DIR);
+ }
+
+}
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/IdentityTranslatorTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/IdentityTranslatorTest.java
index 4e9cdcb..adeb42f 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/IdentityTranslatorTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/IdentityTranslatorTest.java
@@ -57,6 +57,6 @@
yangPluginConfig.setCodeGenDir(DIR);
utilManager.translateToJava(yangPluginConfig);
compileCode(COMP);
- //deleteDirectory(DIR);
+ deleteDirectory(DIR);
}
}
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java
index 6ec65b9..e80bf0b 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/InterJarLinkerTest.java
@@ -49,6 +49,7 @@
import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
import static org.onosproject.yangutils.utils.UtilConstants.TEMP;
import static org.onosproject.yangutils.utils.UtilConstants.YANG_RESOURCES;
+import static org.onosproject.yangutils.utils.io.impl.YangFileScanner.getYangFiles;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
/**
@@ -78,7 +79,7 @@
@Test
public void processSingleJarLinking()
throws IOException, MojoExecutionException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(YANG_FILES_DIR));
+ utilManager.createYangFileInfoSet(getYangFiles(YANG_FILES_DIR));
Set<YangFileInfo> info = utilManager.getYangFileInfoSet();
int size1 = info.size();
utilManager.parseYangFileInfoSet();
@@ -104,7 +105,7 @@
@Test
public void processMultipleJarLinking()
throws IOException, MojoExecutionException {
- utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(YANG_FILES_DIR));
+ utilManager.createYangFileInfoSet(getYangFiles(YANG_FILES_DIR));
Set<YangFileInfo> info = utilManager.getYangFileInfoSet();
int size1 = info.size();
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/ProcessSubTreeCodeGenTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/ProcessSubTreeCodeGenTest.java
new file mode 100644
index 0000000..501e2bc
--- /dev/null
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/plugin/manager/ProcessSubTreeCodeGenTest.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.plugin.manager;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.junit.Test;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.utils.io.YangPluginConfig;
+import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.onosproject.yangutils.utils.io.YangPluginConfig.compileCode;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
+
+/**
+ * Unit test case for process sub tree code generation test.
+ */
+public class ProcessSubTreeCodeGenTest {
+
+ private final YangUtilManager utilManager = new YangUtilManager();
+ private static final String DIR = "target/pstf/";
+ private static final String COMP = System.getProperty("user.dir") + File
+ .separator + DIR;
+
+ /**
+ * Checks pst translation should not result in any exception.
+ *
+ * @throws MojoExecutionException
+ */
+ @Test
+ public void processTranslator() throws IOException, ParserException, MojoExecutionException {
+
+ deleteDirectory(DIR);
+ String searchDir = "src/test/resources/pstcodegen";
+ utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
+ utilManager.parseYangFileInfoSet();
+ utilManager.createYangNodeSet();
+ utilManager.resolveDependenciesUsingLinker();
+
+ YangPluginConfig yangPluginConfig = new YangPluginConfig();
+ yangPluginConfig.setCodeGenDir(DIR);
+ utilManager.translateToJava(yangPluginConfig);
+ compileCode(COMP);
+ //deleteDirectory(DIR);
+ }
+
+}
diff --git a/plugin/maven/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java b/plugin/maven/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
index a6fdf76..6a31ba0 100644
--- a/plugin/maven/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
+++ b/plugin/maven/src/test/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGeneratorTest.java
@@ -203,7 +203,7 @@
String method = getConstructor(testAttr, GENERATE_SERVICE_AND_MANAGER
);
assertThat(true, is(method.contains(
- THIS + PERIOD + ATTRIBUTE_NAME + SPACE + EQUAL + SPACE +
+ ATTRIBUTE_NAME + SPACE + EQUAL + SPACE +
BUILDER_LOWER_CASE + OBJECT + PERIOD +
GET_METHOD_PREFIX + CLASS_NAME + OPEN_PARENTHESIS +
CLOSE_PARENTHESIS + SEMI_COLON)));
diff --git a/plugin/maven/src/test/resources/choiceAugment/all.yang b/plugin/maven/src/test/resources/choiceAugment/all.yang
deleted file mode 100644
index 4c08537..0000000
--- a/plugin/maven/src/test/resources/choiceAugment/all.yang
+++ /dev/null
@@ -1,128 +0,0 @@
-module ietf-inet {
-
- namespace "yang:all";
- prefix "inet";
- yang-version 1;
-
- choice name {
- case a {
- leaf udp {
- type empty;
- }
- }
- case b {
- leaf tcp {
- type empty;
- }
- }
- }
-
-
- container c {
- choice name {
- case a {
- leaf udp {
- type empty;
- }
- }
- case b {
- leaf tcp {
- type empty;
- }
- }
- }
- }
-
- list l {
- config false;
-choice name {
- case a {
- leaf udp {
- type empty;
- }
- }
- case b {
- leaf tcp {
- type empty;
- }
- }
- }
- }
-
-
- grouping g {
- choice name {
- case a {
- leaf udp {
- type empty;
- }
- }
- case b {
- leaf tcp {
- type empty;
- }
- }
- }
- }
-
- notification n {
- choice name {
- case a {
- leaf udp {
- type empty;
- }
- }
- case b {
- leaf tcp {
- type empty;
- }
- }
- }
- }
- rpc r {
- input {
- choice name {
- case a {
- leaf udp {
- type empty;
- }
- }
- case b {
- leaf tcp {
- type empty;
- }
- }
- }
- }
- output {
- choice name {
- case a {
- leaf udp {
- type empty;
- }
- }
- case b {
- leaf tcp {
- type empty;
- }
- }
- }
- }
- }
-
- augment /name {
- choice name {
- case a {
- leaf udp {
- type empty;
- }
- }
- case b {
- leaf tcp {
- type empty;
- }
- }
- }
- }
-
-}
\ No newline at end of file
diff --git a/plugin/maven/src/test/resources/choiceTranslator/all.yang b/plugin/maven/src/test/resources/choiceTranslator/all.yang
new file mode 100644
index 0000000..be2fd07
--- /dev/null
+++ b/plugin/maven/src/test/resources/choiceTranslator/all.yang
@@ -0,0 +1,157 @@
+module all {
+
+ namespace "yang:all";
+ prefix "all";
+ yang-version 1;
+
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+
+
+ container c {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+
+ list l {
+ config false;
+choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+
+
+ grouping g {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+ rpc r {
+ input {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+ output {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+ }
+
+ augment /name {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ container cont1 {
+ container cont2 {
+ choice name {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ container cont1 {
+ container cont2 {
+ leaf udp1 {
+ type empty;
+ }
+ }
+ leaf udp2 {
+ type empty;
+ }
+ }
+ }
+ case b {
+ leaf tcp3 {
+ type empty;
+ }
+ }
+ }
+ leaf udp4 {
+ type empty;
+ }
+ }
+ leaf udp5 {
+ type empty;
+ }
+ }
+ }
+ case b {
+ leaf tcp2 {
+ type empty;
+ }
+ }
+ }
+ choice name1 {
+ case a {
+ leaf udp {
+ type empty;
+ }
+ }
+ case b {
+ leaf tcp {
+ type empty;
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/plugin/maven/src/test/resources/grouping/grouping.yang b/plugin/maven/src/test/resources/grouping/grouping.yang
new file mode 100644
index 0000000..518150f
--- /dev/null
+++ b/plugin/maven/src/test/resources/grouping/grouping.yang
@@ -0,0 +1,58 @@
+module grouping {
+
+ namespace "yang:grouping";
+ prefix "grouping";
+ yang-version 1;
+ revision 2016-10-08;
+
+ grouping link-details {
+ leaf link-id {
+ type union {
+ type int32;
+ type uint16;
+ type enumeration {
+ enum one;
+ enum two;
+ enum five {
+ value 5;
+ }
+ enum six-square {
+ value 36;
+ }
+ }
+ }
+ }
+ typedef group {
+ type bits {
+ bit disable-nagle {
+ position 0;
+ }
+ bit auto-sense-speed {
+ position 1;
+ }
+ bit Mb-only {
+ position 2;
+ }
+ }
+ }
+ container link {
+ leaf port {
+ type int32;
+ }
+
+ leaf-list port-id {
+ type string;
+ }
+ list areas {
+ key "name1";
+ leaf name1 {
+ type string;
+ }
+ }
+ }
+ }
+
+ container cont2 {
+ uses link-details;
+ }
+}
diff --git a/plugin/maven/src/test/resources/pstcodegen/test.yang b/plugin/maven/src/test/resources/pstcodegen/test.yang
new file mode 100644
index 0000000..93e1476
--- /dev/null
+++ b/plugin/maven/src/test/resources/pstcodegen/test.yang
@@ -0,0 +1,83 @@
+module test {
+ namespace "test:test";
+ prefix test;
+
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ leaf-list leaf-list1 {
+ type int32;
+ }
+ list list1 {
+ key "name";
+ leaf name {
+ type string;
+ }
+ }
+ container cont2 {
+ leaf leaf2 {
+ type int32;
+ }
+ }
+ }
+ leaf leaf2 {
+ type int32;
+ }
+ leaf-list leaf-list2 {
+ type int32;
+ }
+ list list2 {
+ key "name";
+ leaf name {
+ type string;
+ }
+ }
+ choice choice1 {
+ case case1 {
+ leaf leaf3 {
+ type int32;
+ }
+ leaf-list leaf-list3 {
+ type int32;
+ }
+ list list3 {
+ key "name";
+ leaf name {
+ type string;
+ }
+ }
+ }
+ }
+ grouping group1 {
+ container cont1 {
+ leaf leaf1 {
+ type int32;
+ }
+ leaf-list leaf-list1 {
+ type int32;
+ }
+ list list1 {
+ key "name";
+ leaf name {
+ type string;
+ }
+ }
+ container cont2 {
+ leaf leaf2 {
+ type int32;
+ }
+ }
+ }
+ }
+ rpc rpc1 {
+ input {
+ uses group1;
+ }
+ }
+ augment /cont1/list1 {
+ leaf leaf2 {
+ type int64;
+ }
+ }
+}
\ No newline at end of file