multiFileYangTranslator
Change-Id: I2adfef3acaec4bd74ba2c487404d2c655b800988
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/CollisionDetector.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/CollisionDetector.java
index 7d37929..69ff0c0 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/CollisionDetector.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/CollisionDetector.java
@@ -28,23 +28,25 @@
* Checks for the colliding child.
*
* @param identifierName name of identifier for which collision to be
- * checked
+ * checked
* @param dataType type of the YANG construct for which collision to be
- * checked
+ * checked
* @throws DataModelException if there is any collision in YANG rules in
* parsed data, corresponding exception should be thrown
*/
- void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException;
+ void detectCollidingChild(String identifierName, YangConstructType dataType)
+ throws DataModelException;
/**
* Check for the self collision.
*
* @param identifierName name of identifier for which collision to be
- * checked
+ * checked
* @param dataType type of the YANG construct for which collision to be
- * checked
+ * checked
* @throws DataModelException if there is any collision in YANG rules in
- * parsed data, corresponding exception should be thrown
+ * parsed data, corresponding exception should be thrown
*/
- void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException;
+ void detectSelfCollision(String identifierName, YangConstructType dataType)
+ throws DataModelException;
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasRpcNotification.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/RpcNotificationContainer.java
similarity index 93%
rename from utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasRpcNotification.java
rename to utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/RpcNotificationContainer.java
index 9d4d5f1..2d29f9e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasRpcNotification.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/RpcNotificationContainer.java
@@ -19,5 +19,5 @@
/**
* Represents class having rpc and notification.
*/
-public interface HasRpcNotification {
+public interface RpcNotificationContainer {
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEntityToResolveInfo.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEntityToResolveInfo.java
index aa95899..229625c 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEntityToResolveInfo.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangEntityToResolveInfo.java
@@ -19,6 +19,8 @@
/**
* Represents information about entity being resolved.
+ *
+ * @param <T> type of entity being resolved, uses / grouping
*/
public class YangEntityToResolveInfo<T> {
@@ -58,13 +60,19 @@
/**
* Sets parent node which contains the entity to be resolved.
*
- * @param holderOfEntityToResolve parent node which contains the entity to be resolved
+ * @param holderOfEntityToResolve parent node which contains the entity to
+ * be resolved
*/
public void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve) {
this.holderOfEntityToResolve = holderOfEntityToResolve;
}
-
+ /**
+ * Retrieves the prefix of the entity.
+ *
+ * @return entities prefix
+ * @throws DataModelException data model error
+ */
public String getEntityPrefix()
throws DataModelException {
if (getEntityToResolve() == null) {
@@ -72,11 +80,11 @@
}
String prefix;
- T entityToResolve = getEntityToResolve();
- if (entityToResolve instanceof YangType) {
- prefix = ((YangType<?>) entityToResolve).getPrefix();
- } else if (entityToResolve instanceof YangUses) {
- prefix = ((YangUses) entityToResolve).getPrefix();
+ T entityToBeResolved = getEntityToResolve();
+ if (entityToBeResolved instanceof YangType) {
+ prefix = ((YangType<?>) entityToBeResolved).getPrefix();
+ } else if (entityToBeResolved instanceof YangUses) {
+ prefix = ((YangUses) entityToBeResolved).getPrefix();
} else {
throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
index 83091b1..c9808a2 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeaf.java
@@ -53,10 +53,12 @@
* | when | 7.19.5 | 0..1 | - TODO |
* +--------------+---------+-------------+------------------+
*/
+
/**
* Represents leaf data represented in YANG.
*/
-public class YangLeaf implements YangCommonInfo, Parsable {
+public class YangLeaf
+ implements YangCommonInfo, Parsable {
/**
* Name of leaf.
@@ -109,7 +111,7 @@
*
* @return the leaf name
*/
- public String getLeafName() {
+ public String getName() {
return name;
}
@@ -270,7 +272,8 @@
* @throws DataModelException a violation of data model rules
*/
@Override
- public void validateDataOnEntry() throws DataModelException {
+ public void validateDataOnEntry()
+ throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
@@ -281,7 +284,8 @@
* @throws DataModelException a violation of data model rules
*/
@Override
- public void validateDataOnExit() throws DataModelException {
+ public void validateDataOnExit()
+ throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
index 809bb8c..0e0bc3e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
@@ -49,10 +49,12 @@
* | when | 7.19.5 | 0..1 | -TODO |
* +--------------+---------+-------------+------------------+
*/
+
/**
* Represents leaf-list data represented in YANG.
*/
-public class YangLeafList implements YangCommonInfo, Parsable {
+public class YangLeafList
+ implements YangCommonInfo, Parsable {
/**
* Name of leaf-list.
@@ -132,7 +134,7 @@
*
* @return the leaf-list name
*/
- public String getLeafName() {
+ public String getName() {
return name;
}
@@ -311,7 +313,8 @@
* @throws DataModelException a violation of data model rules
*/
@Override
- public void validateDataOnEntry() throws DataModelException {
+ public void validateDataOnEntry()
+ throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
@@ -322,7 +325,8 @@
* @throws DataModelException a violation of data model rules
*/
@Override
- public void validateDataOnExit() throws DataModelException {
+ public void validateDataOnExit()
+ throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
index f743f42..e82132f 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
@@ -541,7 +541,7 @@
*/
for (String key : keys) {
for (YangLeaf leaf : leaves) {
- if (key.equals(leaf.getLeafName())) {
+ if (key.equals(leaf.getName())) {
if (leaf.getDataType().getDataType() == YangDataTypes.EMPTY) {
throw new DataModelException(" A leaf that is part of the key must not be the built-in " +
"type \"empty\".");
@@ -586,7 +586,7 @@
*/
for (String key : keys) {
for (YangLeafList leafList : leafLists) {
- if (key.equals(leafList.getLeafName())) {
+ if (key.equals(leafList.getName())) {
if (leafList.getDataType().getDataType() == YangDataTypes.EMPTY) {
throw new DataModelException(" A leaf-list that is part of the key must not be the built-in " +
"type \"empty\".");
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
index c902389..f737e32 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
@@ -17,6 +17,7 @@
import java.util.LinkedList;
import java.util.List;
+
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.utils.YangConstructType;
@@ -68,8 +69,8 @@
* Represents data model node to maintain information defined in YANG module.
*/
public class YangModule extends YangNode
- implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo,
- HasRpcNotification {
+ implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
+ RpcNotificationContainer {
/**
* Name of the module.
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
index ae29433..811c76e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNode.java
@@ -234,8 +234,10 @@
* Clone the current node contents and create a new node.
*
* @return cloned node
- * @throws CloneNotSupportedException clone is not supported by the referred node
+ * @throws CloneNotSupportedException clone is not supported by the referred
+ * node
*/
+ @Override
public YangNode clone()
throws CloneNotSupportedException {
YangNode clonedNode = (YangNode) super.clone();
@@ -247,8 +249,9 @@
}
/**
- * Clone the subtree from the specified source node to the mentioned target node.
- * The source and target root node cloning is carried out by the caller.
+ * Clone the subtree from the specified source node to the mentioned target
+ * node. The source and target root node cloning is carried out by the
+ * caller.
*
* @param srcRootNode source node for sub tree cloning
* @param dstRootNode destination node where the sub tree needs to be cloned
@@ -260,7 +263,6 @@
YangNode nextNodeToClone = srcRootNode;
TraversalType curTraversal;
-
YangNode clonedTreeCurNode = dstRootNode;
YangNode newNode = null;
@@ -286,6 +288,7 @@
newNode = nextNodeToClone.clone();
detectCollisionWhileCloning(clonedTreeCurNode, newNode, curTraversal);
}
+
if (curTraversal == CHILD) {
/**
@@ -294,7 +297,8 @@
clonedTreeCurNode.addChild(newNode);
/**
- * update the cloned tree's travesal current node as the new node.
+ * update the cloned tree's traversal current node as the
+ * new node.
*/
clonedTreeCurNode = newNode;
} else if (curTraversal == SIBILING) {
@@ -339,8 +343,8 @@
*/
private static void detectCollisionWhileCloning(YangNode currentNode, YangNode newNode, TraversalType addAs)
throws DataModelException {
- if ((!(currentNode instanceof CollisionDetector))
- || (!(newNode instanceof Parsable))) {
+ if (!(currentNode instanceof CollisionDetector)
+ || !(newNode instanceof Parsable)) {
throw new DataModelException("Node in data model tree does not support collision detection");
}
@@ -376,9 +380,10 @@
if (newSibling.getParent() == null) {
/**
- * Since the siblings needs to have a common parent, set the parent as the current node's parent
+ * Since the siblings needs to have a common parent, set the parent
+ * as the current node's parent
*/
- newSibling.setParent(this.getParent());
+ newSibling.setParent(getParent());
} else {
throw new DataModelException("Node is already part of a tree, and cannot be added as a sibling");
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasResolutionInfo.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangReferenceResolver.java
similarity index 98%
rename from utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasResolutionInfo.java
rename to utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangReferenceResolver.java
index 4e786ff..e9ae54d 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasResolutionInfo.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangReferenceResolver.java
@@ -23,7 +23,7 @@
* Abstraction of YANG dependency resolution information. Abstracted to obtain the
* resolution information.
*/
-public interface HasResolutionInfo {
+public interface YangReferenceResolver {
/**
* Returns unresolved resolution list.
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
index 9db0469..d762151 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
@@ -17,6 +17,7 @@
import java.util.LinkedList;
import java.util.List;
+
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.utils.YangConstructType;
@@ -76,8 +77,8 @@
* Represents data model node to maintain information defined in YANG sub-module.
*/
public class YangSubModule extends YangNode
- implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo,
- HasRpcNotification {
+ implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver,
+ RpcNotificationContainer {
/**
* Name of sub module.
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeContainer.java
similarity index 95%
rename from utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasType.java
rename to utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeContainer.java
index e7a5c73..c22bfc0 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeContainer.java
@@ -21,7 +21,7 @@
/**
* Represents the holder with type(s).
*/
-public interface HasType {
+public interface YangTypeContainer {
/**
* Returns type list.
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
index 49eafff..2eac613 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
@@ -54,7 +54,7 @@
/**
* Represents data model node to maintain information defined in YANG typedef.
*/
-public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable, HasType {
+public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable, YangTypeContainer {
/**
* Default value in string, needs to be converted to the target object,
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java
index eb0e34d..038cf38 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUnion.java
@@ -47,7 +47,7 @@
/**
* Represents data model node to maintain information defined in YANG union.
*/
-public class YangUnion extends YangNode implements Parsable, HasType {
+public class YangUnion extends YangNode implements Parsable, YangTypeContainer {
// List of YANG type.
private List<YangType<?>> typeList;
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
index 16f45c4..55fbaf4 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
@@ -276,14 +276,14 @@
YangLeavesHolder usesParentLeavesHolder = (YangLeavesHolder) usesParentNode;
if (referredGrouping.getListOfLeaf() != null) {
for (YangLeaf leaf : referredGrouping.getListOfLeaf()) {
- ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leaf.getLeafName(),
+ ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leaf.getName(),
YangConstructType.LEAF_DATA);
usesParentLeavesHolder.addLeaf(leaf);
}
}
if (referredGrouping.getListOfLeafList() != null) {
for (YangLeafList leafList : referredGrouping.getListOfLeafList()) {
- ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leafList.getLeafName(),
+ ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leafList.getName(),
YangConstructType.LEAF_LIST_DATA);
usesParentLeavesHolder.addLeafList(leafList);
}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
index e848299..928e87b 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
@@ -19,7 +19,7 @@
import java.util.List;
import org.onosproject.yangutils.datamodel.CollisionDetector;
-import org.onosproject.yangutils.datamodel.HasResolutionInfo;
+import org.onosproject.yangutils.datamodel.YangReferenceResolver;
import org.onosproject.yangutils.datamodel.YangImport;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
@@ -112,9 +112,9 @@
return;
}
for (YangLeaf leaf : listOfLeaf) {
- if (leaf.getLeafName().equals(identifierName)) {
+ if (leaf.getName().equals(identifierName)) {
throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf \""
- + leaf.getLeafName() + "\"");
+ + leaf.getName() + "\"");
}
}
}
@@ -133,10 +133,10 @@
if (listOfLeafList == null) {
return;
}
- for (YangLeafList leafList : listOfLeafList) {
- if (leafList.getLeafName().equals(identifierName)) {
+ for (YangLeafList leafList : listOfLeafList) {
+ if (leafList.getName().equals(identifierName)) {
throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf " +
- "list \"" + leafList.getLeafName() + "\"");
+ "list \"" + leafList.getName() + "\"");
}
}
}
@@ -154,13 +154,13 @@
/* get the module node to add maintain the list of nested reference */
YangNode curNode = resolutionInfo.getEntityToResolveInfo()
.getHolderOfEntityToResolve();
- while (!(curNode instanceof HasResolutionInfo)) {
+ while (!(curNode instanceof YangReferenceResolver)) {
curNode = curNode.getParent();
if (curNode == null) {
throw new DataModelException("Internal datamodel error: Datamodel tree is not correct");
}
}
- HasResolutionInfo resolutionNode = (HasResolutionInfo) curNode;
+ YangReferenceResolver resolutionNode = (YangReferenceResolver) curNode;
if (!isPrefixValid(resolutionInfo.getEntityToResolveInfo().getEntityPrefix(),
resolutionNode)) {
@@ -176,7 +176,7 @@
* @param resolutionNode uses/type node which has the prefix with it
* @return whether prefix is valid or not
*/
- private static boolean isPrefixValid(String entityPrefix, HasResolutionInfo resolutionNode) {
+ private static boolean isPrefixValid(String entityPrefix, YangReferenceResolver resolutionNode) {
if (entityPrefix == null) {
return true;
}
@@ -215,7 +215,7 @@
* @throws DataModelException a violation of data model rules
*/
public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList,
- HasResolutionInfo dataModelRootNode)
+ YangReferenceResolver dataModelRootNode)
throws DataModelException {
for (YangResolutionInfo resolutionInfo : resolutionList) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/YangDataModelFactory.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/YangDataModelFactory.java
index 686360e..aff53c4 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/YangDataModelFactory.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/YangDataModelFactory.java
@@ -20,38 +20,42 @@
import org.onosproject.yangutils.datamodel.YangChoice;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangGrouping;
+import org.onosproject.yangutils.datamodel.YangInput;
import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNotification;
+import org.onosproject.yangutils.datamodel.YangOutput;
+import org.onosproject.yangutils.datamodel.YangRpc;
import org.onosproject.yangutils.datamodel.YangSubModule;
+import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.datamodel.YangUnion;
import org.onosproject.yangutils.datamodel.YangUses;
-import org.onosproject.yangutils.datamodel.YangNotification;
-import org.onosproject.yangutils.datamodel.YangRpc;
-import org.onosproject.yangutils.datamodel.YangInput;
-import org.onosproject.yangutils.datamodel.YangOutput;
+import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaAugment;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaCase;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaChoice;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaContainer;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaGrouping;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInput;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeaf;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaLeafList;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaList;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModule;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotification;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaOutput;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaRpc;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModule;
+import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUnion;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaUses;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaNotification;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaRpc;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaInput;
-import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaOutput;
-import org.onosproject.yangutils.translator.exception.TranslatorException;
/**
- *Represents factory to create data model objects based on the target file type.
+ * Represents factory to create data model objects based on the target file type.
*/
public final class YangDataModelFactory {
@@ -65,7 +69,7 @@
* Based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangModule getYangModuleNode(GeneratedLanguage targetLanguage) {
@@ -83,7 +87,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangAugment getYangAugmentNode(GeneratedLanguage targetLanguage) {
@@ -101,7 +105,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangCase getYangCaseNode(GeneratedLanguage targetLanguage) {
@@ -119,7 +123,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangChoice getYangChoiceNode(GeneratedLanguage targetLanguage) {
@@ -137,7 +141,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangContainer getYangContainerNode(GeneratedLanguage targetLanguage) {
@@ -155,7 +159,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangGrouping getYangGroupingNode(GeneratedLanguage targetLanguage) {
@@ -173,7 +177,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangList getYangListNode(GeneratedLanguage targetLanguage) {
@@ -191,7 +195,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangSubModule getYangSubModuleNode(GeneratedLanguage targetLanguage) {
@@ -209,7 +213,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangTypeDef getYangTypeDefNode(GeneratedLanguage targetLanguage) {
@@ -227,7 +231,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangUnion getYangUnionNode(GeneratedLanguage targetLanguage) {
@@ -245,7 +249,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangUses getYangUsesNode(GeneratedLanguage targetLanguage) {
@@ -263,7 +267,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangNotification getYangNotificationNode(GeneratedLanguage targetLanguage) {
@@ -281,7 +285,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangLeaf getYangLeaf(GeneratedLanguage targetLanguage) {
@@ -294,11 +298,30 @@
}
}
}
+
/**
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
+ * @return the corresponding inherited node based on the target language
+ */
+ public static YangLeafList getYangLeafList(GeneratedLanguage targetLanguage) {
+ switch (targetLanguage) {
+ case JAVA_GENERATION: {
+ return new YangJavaLeafList();
+ }
+ default: {
+ throw new RuntimeException("Only YANG to Java is supported.");
+ }
+ }
+ }
+
+ /**
+ * Returns based on the target language generate the inherited data model node.
+ *
+ * @param targetLanguage target language in which YANG mapping needs to be
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangRpc getYangRpcNode(GeneratedLanguage targetLanguage) {
@@ -316,7 +339,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangInput getYangInputNode(GeneratedLanguage targetLanguage) {
@@ -334,7 +357,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangOutput getYangOutputNode(GeneratedLanguage targetLanguage) {
@@ -352,7 +375,7 @@
* Returns based on the target language generate the inherited data model node.
*
* @param targetLanguage target language in which YANG mapping needs to be
- * generated
+ * generated
* @return the corresponding inherited node based on the target language
*/
public static YangJavaEnumeration getYangEnumerationNode(GeneratedLanguage targetLanguage) {
@@ -365,4 +388,21 @@
}
}
}
+ /**
+ * Returns based on the target language generate the inherited data model node.
+ *
+ * @param targetLanguage target language in which YANG mapping needs to be
+ * generated
+ * @return the corresponding inherited node based on the target language
+ */
+ public static YangType getYangType(GeneratedLanguage targetLanguage) {
+ switch (targetLanguage) {
+ case JAVA_GENERATION: {
+ return new YangJavaType();
+ }
+ default: {
+ throw new RuntimeException("Only YANG to Java is supported.");
+ }
+ }
+ }
}