Vinod Kumar S
Committed by Gerrit Code Review

multiFileYangTranslator

Change-Id: I2adfef3acaec4bd74ba2c487404d2c655b800988
Showing 108 changed files with 1014 additions and 1126 deletions
......@@ -28,23 +28,25 @@ public interface CollisionDetector {
* 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;
}
......
......@@ -19,5 +19,5 @@ package org.onosproject.yangutils.datamodel;
/**
* Represents class having rpc and notification.
*/
public interface HasRpcNotification {
public interface RpcNotificationContainer {
}
......
......@@ -19,6 +19,8 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
/**
* Represents information about entity being resolved.
*
* @param <T> type of entity being resolved, uses / grouping
*/
public class YangEntityToResolveInfo<T> {
......@@ -58,13 +60,19 @@ public class YangEntityToResolveInfo<T> {
/**
* 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 @@ public class YangEntityToResolveInfo<T> {
}
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");
}
......
......@@ -53,10 +53,12 @@ import org.onosproject.yangutils.utils.YangConstructType;
* | 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 @@ public class YangLeaf implements YangCommonInfo, Parsable {
*
* @return the leaf name
*/
public String getLeafName() {
public String getName() {
return name;
}
......@@ -270,7 +272,8 @@ public class YangLeaf implements YangCommonInfo, Parsable {
* @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 @@ public class YangLeaf implements YangCommonInfo, Parsable {
* @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
}
......
......@@ -49,10 +49,12 @@ import org.onosproject.yangutils.utils.YangConstructType;
* | 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 @@ public class YangLeafList implements YangCommonInfo, Parsable {
*
* @return the leaf-list name
*/
public String getLeafName() {
public String getName() {
return name;
}
......@@ -311,7 +313,8 @@ public class YangLeafList implements YangCommonInfo, Parsable {
* @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 @@ public class YangLeafList implements YangCommonInfo, Parsable {
* @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
}
......
......@@ -541,7 +541,7 @@ public class YangList extends YangNode
*/
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 @@ public class YangList extends YangNode
*/
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\".");
......
......@@ -17,6 +17,7 @@ package org.onosproject.yangutils.datamodel;
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 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi
* 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.
......
......@@ -234,8 +234,10 @@ public abstract class YangNode
* 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 @@ public abstract class YangNode
}
/**
* 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 @@ public abstract class YangNode
YangNode nextNodeToClone = srcRootNode;
TraversalType curTraversal;
YangNode clonedTreeCurNode = dstRootNode;
YangNode newNode = null;
......@@ -286,6 +288,7 @@ public abstract class YangNode
newNode = nextNodeToClone.clone();
detectCollisionWhileCloning(clonedTreeCurNode, newNode, curTraversal);
}
if (curTraversal == CHILD) {
/**
......@@ -294,7 +297,8 @@ public abstract class YangNode
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 @@ public abstract class YangNode
*/
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 @@ public abstract class YangNode
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");
......
......@@ -23,7 +23,7 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
* Abstraction of YANG dependency resolution information. Abstracted to obtain the
* resolution information.
*/
public interface HasResolutionInfo {
public interface YangReferenceResolver {
/**
* Returns unresolved resolution list.
......
......@@ -17,6 +17,7 @@ package org.onosproject.yangutils.datamodel;
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 @@ import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLi
* 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.
......
......@@ -21,7 +21,7 @@ import java.util.List;
/**
* Represents the holder with type(s).
*/
public interface HasType {
public interface YangTypeContainer {
/**
* Returns type list.
......
......@@ -54,7 +54,7 @@ import org.onosproject.yangutils.utils.YangConstructType;
/**
* 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,
......
......@@ -47,7 +47,7 @@ import org.onosproject.yangutils.utils.YangConstructType;
/**
* 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;
......
......@@ -276,14 +276,14 @@ public class YangUses
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);
}
......
......@@ -19,7 +19,7 @@ package org.onosproject.yangutils.datamodel.utils;
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 @@ public final class DataModelUtils {
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 @@ public final class DataModelUtils {
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 @@ public final class DataModelUtils {
/* 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 @@ public final class DataModelUtils {
* @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 @@ public final class DataModelUtils {
* @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) {
......
......@@ -17,7 +17,7 @@
package org.onosproject.yangutils.linker;
import java.util.Map;
import org.onosproject.yangutils.datamodel.HasResolutionInfo;
import org.onosproject.yangutils.datamodel.YangReferenceResolver;
/**
* Abstraction of entity which provides linking service of YANG files.
......@@ -30,6 +30,6 @@ public interface YangLinker {
*
* @param fileMapEntry map entry for which resolution is to be done
* @param yangFilesMap map of dependent file and resolution information*/
void resolveDependencies(Map.Entry<String, HasResolutionInfo> fileMapEntry, Map<String,
HasResolutionInfo> yangFilesMap);
void resolveDependencies(Map.Entry<String, YangReferenceResolver> fileMapEntry, Map<String,
YangReferenceResolver> yangFilesMap);
}
......
......@@ -52,8 +52,8 @@ import org.onosproject.yangutils.parser.impl.listeners.MandatoryListener;
import org.onosproject.yangutils.parser.impl.listeners.MaxElementsListener;
import org.onosproject.yangutils.parser.impl.listeners.MinElementsListener;
import org.onosproject.yangutils.parser.impl.listeners.ModuleListener;
import org.onosproject.yangutils.parser.impl.listeners.NamespaceListener;
import org.onosproject.yangutils.parser.impl.listeners.NotificationListener;
import org.onosproject.yangutils.parser.impl.listeners.NamespaceListener;
import org.onosproject.yangutils.parser.impl.listeners.OrganizationListener;
import org.onosproject.yangutils.parser.impl.listeners.OutputListener;
import org.onosproject.yangutils.parser.impl.listeners.PatternRestrictionListener;
......
......@@ -96,10 +96,10 @@ public final class BitsListener {
switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
bitsNode.setBitsName(((YangLeaf) tmpData).getLeafName());
bitsNode.setBitsName(((YangLeaf) tmpData).getName());
break;
case LEAF_LIST_DATA:
bitsNode.setBitsName(((YangLeafList) tmpData).getLeafName());
bitsNode.setBitsName(((YangLeafList) tmpData).getName());
break;
// TODO typedef, union, deviate.
default:
......
......@@ -112,7 +112,7 @@ public final class EnumerationListener {
switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
// Set the name of enumeration same as leaf.
enumerationNode.setName(((YangLeaf) tmpData).getLeafName() + ENUMERATION_CLASS_SUFFIX);
enumerationNode.setName(((YangLeaf) tmpData).getName() + ENUMERATION_CLASS_SUFFIX);
// Pop the stack entry to obtain the parent YANG node.
Parsable leaf = listener.getParsedDataStack().pop();
// Add the enumeration node to the parent holder of leaf.
......@@ -122,7 +122,7 @@ public final class EnumerationListener {
break;
case LEAF_LIST_DATA:
// Set the name of enumeration same as leaf list.
enumerationNode.setName(((YangLeafList) tmpData).getLeafName() + ENUMERATION_CLASS_SUFFIX);
enumerationNode.setName(((YangLeafList) tmpData).getName() + ENUMERATION_CLASS_SUFFIX);
// Pop the stack entry to obtain the parent YANG node.
Parsable leafList = listener.getParsedDataStack().pop();
// Add the enumeration node to the parent holder of leaf.
......
......@@ -46,10 +46,12 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateMutuallyExclusiveChilds;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.GROUPING_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.TYPEDEF_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -166,5 +168,7 @@ public final class GroupingListener {
validateCardinalityMaxOne(ctx.descriptionStatement(), DESCRIPTION_DATA, GROUPING_DATA,
ctx.identifier().getText());
validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, GROUPING_DATA, ctx.identifier().getText());
validateMutuallyExclusiveChilds(ctx.typedefStatement(), TYPEDEF_DATA, ctx.groupingStatement(), GROUPING_DATA,
GROUPING_DATA, ctx.identifier().getText());
}
}
......
......@@ -29,15 +29,15 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G
import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangInputNode;
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.constructExtendedListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
.constructExtendedListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityNonZero;
import static org.onosproject.yangutils.utils.YangConstructType.DATA_DEF_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.INPUT_DATA;
/*
......@@ -80,17 +80,14 @@ public final class InputListener {
* (input), performs validation and updates the data model tree.
*
* @param listener listener's object
* @param ctx context object of the grammar rule
* @param ctx context object of the grammar rule
*/
public static void processInputEntry(TreeWalkListener listener,
GeneratedYangParser.InputStatementContext ctx) {
GeneratedYangParser.InputStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, INPUT_DATA, "", ENTRY);
validateCardinalityNonZero(ctx.dataDefStatement(), DATA_DEF_DATA,
INPUT_DATA, "", ctx);
Parsable curData = listener.getParsedDataStack().peek();
if (curData instanceof YangRpc) {
......@@ -115,10 +112,10 @@ public final class InputListener {
* validations and updates the data model tree.
*
* @param listener listener's object
* @param ctx context object of the grammar rule
* @param ctx context object of the grammar rule
*/
public static void processInputExit(TreeWalkListener listener,
GeneratedYangParser.InputStatementContext ctx) {
GeneratedYangParser.InputStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, INPUT_DATA, "", EXIT);
......
......@@ -23,10 +23,13 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangLeafList;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
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_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
......@@ -106,7 +109,7 @@ public final class LeafListListener {
int charPositionInLine = ctx.getStart().getCharPositionInLine();
detectCollidingChildUtil(listener, line, charPositionInLine, identifier, LEAF_LIST_DATA);
YangLeafList leafList = new YangLeafList();
YangLeafList leafList = getYangLeafList(JAVA_GENERATION);
leafList.setLeafName(identifier);
Parsable tmpData = listener.getParsedDataStack().peek();
......@@ -117,7 +120,7 @@ public final class LeafListListener {
leaves.addLeafList(leafList);
} else {
throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, LEAF_LIST_DATA,
ctx.identifier().getText(), ENTRY));
ctx.identifier().getText(), ENTRY));
}
listener.getParsedDataStack().push(leafList);
}
......
......@@ -16,7 +16,7 @@
package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.HasResolutionInfo;
import org.onosproject.yangutils.datamodel.YangReferenceResolver;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangRevision;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
......@@ -116,7 +116,7 @@ public final class ModuleListener {
ctx.identifier().getText(), EXIT));
}
try {
((HasResolutionInfo) listener.getParsedDataStack().peek()).resolveSelfFileLinking();
((YangReferenceResolver) listener.getParsedDataStack().peek()).resolveSelfFileLinking();
} catch (DataModelException e) {
ParserException parserException = new ParserException(e.getMessage());
parserException.setLine(e.getLineNumber());
......
......@@ -40,10 +40,13 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateMutuallyExclusiveChilds;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.GROUPING_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.NOTIFICATION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.TYPEDEF_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -156,5 +159,7 @@ public final class NotificationListener {
ctx.identifier().getText());
validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, NOTIFICATION_DATA,
ctx.identifier().getText());
validateMutuallyExclusiveChilds(ctx.typedefStatement(), TYPEDEF_DATA, ctx.groupingStatement(), GROUPING_DATA,
NOTIFICATION_DATA, ctx.identifier().getText());
}
}
......
......@@ -29,15 +29,15 @@ import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_G
import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangOutputNode;
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.constructExtendedListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
.constructExtendedListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityNonZero;
import static org.onosproject.yangutils.utils.YangConstructType.DATA_DEF_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.OUTPUT_DATA;
/*
......@@ -80,17 +80,14 @@ public final class OutputListener {
* (output), performs validation and updates the data model tree.
*
* @param listener listener's object
* @param ctx context object of the grammar rule
* @param ctx context object of the grammar rule
*/
public static void processOutputEntry(TreeWalkListener listener,
GeneratedYangParser.OutputStatementContext ctx) {
GeneratedYangParser.OutputStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, OUTPUT_DATA, "", ENTRY);
validateCardinalityNonZero(ctx.dataDefStatement(), DATA_DEF_DATA,
OUTPUT_DATA, "", ctx);
Parsable curData = listener.getParsedDataStack().peek();
if (curData instanceof YangRpc) {
......@@ -115,10 +112,10 @@ public final class OutputListener {
* validations and updates the data model tree.
*
* @param listener listener's object
* @param ctx context object of the grammar rule
* @param ctx context object of the grammar rule
*/
public static void processOutputExit(TreeWalkListener listener,
GeneratedYangParser.OutputStatementContext ctx) {
GeneratedYangParser.OutputStatementContext ctx) {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, OUTPUT_DATA, "", EXIT);
......@@ -129,4 +126,4 @@ public final class OutputListener {
}
listener.getParsedDataStack().pop();
}
}
\ No newline at end of file
}
......
......@@ -37,9 +37,12 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateMutuallyExclusiveChilds;
import static org.onosproject.yangutils.utils.YangConstructType.RPC_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.INPUT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.OUTPUT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.TYPEDEF_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.GROUPING_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
......@@ -154,6 +157,8 @@ public final class RpcListener {
validateCardinalityMaxOne(ctx.referenceStatement(), REFERENCE_DATA, RPC_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.inputStatement(), INPUT_DATA, RPC_DATA, ctx.identifier().getText());
validateCardinalityMaxOne(ctx.outputStatement(), OUTPUT_DATA, RPC_DATA, ctx.identifier().getText());
validateMutuallyExclusiveChilds(ctx.typedefStatement(), TYPEDEF_DATA, ctx.groupingStatement(), GROUPING_DATA,
RPC_DATA, ctx.identifier().getText());
}
}
......
......@@ -16,7 +16,7 @@
package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.HasResolutionInfo;
import org.onosproject.yangutils.datamodel.YangReferenceResolver;
import org.onosproject.yangutils.datamodel.YangRevision;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
......@@ -121,7 +121,7 @@ public final class SubModuleListener {
ctx.identifier().getText(), EXIT));
}
try {
((HasResolutionInfo) listener.getParsedDataStack().peek()).resolveSelfFileLinking();
((YangReferenceResolver) listener.getParsedDataStack().peek()).resolveSelfFileLinking();
} catch (DataModelException e) {
ParserException parserException = new ParserException(e.getMessage());
parserException.setLine(e.getLineNumber());
......
......@@ -34,6 +34,8 @@ import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.datamodel.ResolvableStatus.UNRESOLVED;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo;
import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangType;
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
......@@ -95,7 +97,7 @@ public final class TypeListener {
YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText());
// Create YANG type object and fill the values.
YangType<?> type = new YangType();
YangType<?> type = getYangType(JAVA_GENERATION);
type.setNodeIdentifier(nodeIdentifier);
type.setDataType(yangDataTypes);
......@@ -253,7 +255,7 @@ public final class TypeListener {
* @param ctx context object of the grammar rule
*/
private static void addToResolutionList(YangResolutionInfo<YangType> resolutionInfo,
GeneratedYangParser.TypeStatementContext ctx) {
GeneratedYangParser.TypeStatementContext ctx) {
try {
addResolutionInfo(resolutionInfo);
} catch (DataModelException e) {
......
......@@ -108,7 +108,7 @@ public final class UnionListener {
switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
// Set the name of union same as leaf.
unionNode.setName(((YangLeaf) tmpData).getLeafName() + UNION_CLASS_SUFFIX);
unionNode.setName(((YangLeaf) tmpData).getName() + UNION_CLASS_SUFFIX);
// Pop the stack entry to obtain the parent YANG node.
Parsable leaf = listener.getParsedDataStack().pop();
// Add the union node to the parent holder of leaf.
......@@ -118,7 +118,7 @@ public final class UnionListener {
break;
case LEAF_LIST_DATA:
// Set the name of union same as leaf list.
unionNode.setName(((YangLeafList) tmpData).getLeafName() + UNION_CLASS_SUFFIX);
unionNode.setName(((YangLeafList) tmpData).getName() + UNION_CLASS_SUFFIX);
// Pop the stack entry to obtain the parent YANG node.
Parsable leafList = listener.getParsedDataStack().pop();
// Add the union node to the parent holder of leaf.
......@@ -217,4 +217,4 @@ public final class UnionListener {
}
}
}
}
\ No newline at end of file
}
......
......@@ -44,7 +44,8 @@ public final class GeneratedJavaFileType {
/**
* Interface and class file.
*/
public static final int GENERATE_INTERFACE_WITH_BUILDER = 15;
public static final int GENERATE_INTERFACE_WITH_BUILDER = INTERFACE_MASK
| BUILDER_INTERFACE_MASK | BUILDER_CLASS_MASK | IMPL_CLASS_MASK;
/**
* Java interface corresponding to rpc.
......@@ -54,24 +55,31 @@ public final class GeneratedJavaFileType {
/**
* Interface, class file and rpc.
*/
public static final int GENERATE_MANAGER_WITH_RPC = 31;
public static final int GENERATE_MANAGER_WITH_RPC = GENERATE_INTERFACE_WITH_BUILDER
| GENERATE_RPC_INTERFACE;
// TODO RPC implementation to be integrated with notification.
/**
* Java class corresponding to YANG enumeration.
*/
public static final int GENERATE_ENUM_CLASS = 64;
public static final int GENERATE_ENUM_CLASS = 32;
/**
* Java class corresponding to typedef.
*/
public static final int GENERATE_TYPEDEF_CLASS = 1024;
public static final int GENERATE_TYPEDEF_CLASS = 64;
/**
* Java class corresponding to union.
*/
public static final int GENERATE_UNION_CLASS = 2048;
public static final int GENERATE_UNION_CLASS = 128;
/**
* Java class corresponding to typedef.
*/
public static final int GENERATE_TYPE_CLASS = GENERATE_TYPEDEF_CLASS
| GENERATE_UNION_CLASS;
/**
* Creates an instance of generate java file type.
......
......@@ -39,7 +39,7 @@ public final class JavaCodeGeneratorUtil {
private static YangNode curNode;
/**
* Creates a java code generator util object.
* Creates a java code generator utility object.
*/
private JavaCodeGeneratorUtil() {
}
......@@ -68,29 +68,30 @@ public final class JavaCodeGeneratorUtil {
* @param rootNode root node of the data model tree
* @param yangPlugin YANG plugin config
* @throws IOException when fails to generate java code file the current
* node
* node
*/
public static void generateJavaCode(YangNode rootNode, YangPluginConfig yangPlugin) throws IOException {
public static void generateJavaCode(YangNode rootNode, YangPluginConfig yangPlugin)
throws IOException {
YangNode curNode = rootNode;
YangNode codeGenNode = rootNode;
TraversalType curTraversal = ROOT;
while (curNode != null) {
while (codeGenNode != null) {
if (curTraversal != PARENT) {
setCurNode(curNode);
generateCodeEntry(curNode, yangPlugin);
setCurNode(codeGenNode);
generateCodeEntry(codeGenNode, yangPlugin);
}
if (curTraversal != PARENT && curNode.getChild() != null) {
if (curTraversal != PARENT && codeGenNode.getChild() != null) {
curTraversal = CHILD;
curNode = curNode.getChild();
} else if (curNode.getNextSibling() != null) {
generateCodeExit(curNode);
codeGenNode = codeGenNode.getChild();
} else if (codeGenNode.getNextSibling() != null) {
generateCodeExit(codeGenNode);
curTraversal = SIBILING;
curNode = curNode.getNextSibling();
codeGenNode = codeGenNode.getNextSibling();
} else {
generateCodeExit(curNode);
generateCodeExit(codeGenNode);
curTraversal = PARENT;
curNode = curNode.getParent();
codeGenNode = codeGenNode.getParent();
}
}
}
......@@ -98,15 +99,16 @@ public final class JavaCodeGeneratorUtil {
/**
* Generates the current nodes code snippet.
*
* @param curNode current data model node for which the code needs to be
* generated
* @param codeGenNode current data model node for which the code needs to be
* generated
* @param yangPlugin YANG plugin config
* @throws IOException IO operation exception
*/
private static void generateCodeEntry(YangNode curNode, YangPluginConfig yangPlugin) throws IOException {
private static void generateCodeEntry(YangNode codeGenNode, YangPluginConfig yangPlugin)
throws IOException {
if (curNode instanceof JavaCodeGenerator) {
((JavaCodeGenerator) curNode).generateCodeEntry(yangPlugin);
if (codeGenNode instanceof JavaCodeGenerator) {
((JavaCodeGenerator) codeGenNode).generateCodeEntry(yangPlugin);
} else {
throw new TranslatorException(
"Generated data model node cannot be translated to target language code");
......@@ -116,14 +118,15 @@ public final class JavaCodeGeneratorUtil {
/**
* Generates the current nodes code target code from the snippet.
*
* @param curNode current data model node for which the code needs to be
* generated
* @param codeGenNode current data model node for which the code needs to be
* generated
* @throws IOException IO operation exception
*/
private static void generateCodeExit(YangNode curNode) throws IOException {
private static void generateCodeExit(YangNode codeGenNode)
throws IOException {
if (curNode instanceof JavaCodeGenerator) {
((JavaCodeGenerator) curNode).generateCodeExit();
if (codeGenNode instanceof JavaCodeGenerator) {
((JavaCodeGenerator) codeGenNode).generateCodeExit();
} else {
throw new TranslatorException(
"Generated data model node cannot be translated to target language code");
......@@ -131,31 +134,35 @@ public final class JavaCodeGeneratorUtil {
}
/**
* Free other YANG nodes of data-model tree when error occurs while file generation of current node.
* Free other YANG nodes of data-model tree when error occurs while file
* generation of current node.
*
* @throws DataModelException when fails to do datamodel operations
*/
public static void freeRestResources() {
private static void freeRestResources()
throws DataModelException {
YangNode curNode = getCurNode();
YangNode tempNode = curNode;
YangNode freedNode = getCurNode();
YangNode tempNode = freedNode;
TraversalType curTraversal = ROOT;
while (curNode != tempNode.getParent()) {
while (freedNode != tempNode.getParent()) {
if (curTraversal != PARENT && curNode.getChild() != null) {
if (curTraversal != PARENT && freedNode.getChild() != null) {
curTraversal = CHILD;
curNode = curNode.getChild();
} else if (curNode.getNextSibling() != null) {
freedNode = freedNode.getChild();
} else if (freedNode.getNextSibling() != null) {
curTraversal = SIBILING;
if (curNode != tempNode) {
free(curNode);
if (freedNode != tempNode) {
free(freedNode);
}
curNode = curNode.getNextSibling();
freedNode = freedNode.getNextSibling();
} else {
curTraversal = PARENT;
if (curNode != tempNode) {
free(curNode);
if (freedNode != tempNode) {
free(freedNode);
}
curNode = curNode.getParent();
freedNode = freedNode.getParent();
}
}
}
......@@ -182,10 +189,11 @@ public final class JavaCodeGeneratorUtil {
* Delete Java code files corresponding to the YANG schema.
*
* @param rootNode root node of data-model tree
* @throws IOException when fails to delete java code file the current node
* @throws IOException when fails to delete java code file the current node
* @throws DataModelException when fails to do datamodel operations
*/
public static void translatorErrorHandler(YangNode rootNode) throws IOException, DataModelException {
public static void translatorErrorHandler(YangNode rootNode)
throws IOException, DataModelException {
/**
* Free other resources where translator has failed.
......@@ -195,24 +203,24 @@ public final class JavaCodeGeneratorUtil {
/**
* Start removing all open files.
*/
YangNode curNode = rootNode;
setCurNode(curNode.getChild());
YangNode tempNode = rootNode;
setCurNode(tempNode.getChild());
TraversalType curTraversal = ROOT;
while (curNode != null) {
while (tempNode != null) {
if (curTraversal != PARENT) {
close(curNode);
close(tempNode);
}
if (curTraversal != PARENT && curNode.getChild() != null) {
if (curTraversal != PARENT && tempNode.getChild() != null) {
curTraversal = CHILD;
curNode = curNode.getChild();
} else if (curNode.getNextSibling() != null) {
tempNode = tempNode.getChild();
} else if (tempNode.getNextSibling() != null) {
curTraversal = SIBILING;
curNode = curNode.getNextSibling();
tempNode = tempNode.getNextSibling();
} else {
curTraversal = PARENT;
curNode = curNode.getParent();
tempNode = tempNode.getParent();
}
}
......@@ -220,15 +228,17 @@ public final class JavaCodeGeneratorUtil {
}
/**
* Closes all the current open file handles of node and delete all generated files.
* Closes all the current open file handles of node and delete all generated
* files.
*
* @param curNode current YANG node
* @param node current YANG node
* @throws IOException when fails to do IO operations
*/
private static void close(YangNode curNode) throws IOException {
private static void close(YangNode node)
throws IOException {
if (((HasTempJavaCodeFragmentFiles) curNode).getTempJavaCodeFragmentFiles() != null) {
((HasTempJavaCodeFragmentFiles) curNode).getTempJavaCodeFragmentFiles().close(true);
if (((TempJavaCodeFragmentFilesContainer) node).getTempJavaCodeFragmentFiles() != null) {
((TempJavaCodeFragmentFilesContainer) node).getTempJavaCodeFragmentFiles().close(true);
}
}
}
......
......@@ -19,7 +19,7 @@ package org.onosproject.yangutils.translator.tojava;
* Represents data model nodes which are required to generate java classes, need to support
* java file info.
*/
public interface HasJavaFileInfo {
public interface JavaFileInfoContainer {
/**
* Returns the generated java file information.
......
......@@ -19,10 +19,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import static java.util.Collections.sort;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import static org.onosproject.yangutils.utils.UtilConstants.ARRAY_LIST;
import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED_INFO_CLASS_IMPORT_CLASS;
......@@ -42,6 +38,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
import static java.util.Collections.sort;
/**
* Represents that generated Java file can contain imports.
*/
......@@ -112,33 +110,29 @@ public class JavaImportData {
* denote, it is not added to import collection and needs to be accessed in
* a qualified manner.
*
* @param curNode current data model node
* @param newImportInfo class/interface info being imported
* @return status of new addition of class/interface to the import set
*/
public boolean addImportInfo(YangNode curNode, JavaQualifiedTypeInfo newImportInfo) {
public boolean addImportInfo(JavaQualifiedTypeInfo newImportInfo) {
if (!(curNode instanceof HasJavaImportData)) {
throw new TranslatorException("missing import info in data model node");
}
for (JavaQualifiedTypeInfo curImportInfo : ((HasJavaImportData) curNode).getJavaImportData().getImportSet()) {
for (JavaQualifiedTypeInfo curImportInfo : getImportSet()) {
if (curImportInfo.getClassInfo()
.contentEquals(newImportInfo.getClassInfo())) {
return curImportInfo.getPkgInfo()
.contentEquals(newImportInfo.getPkgInfo());
}
}
((HasJavaImportData) curNode).getJavaImportData().getImportSet().add(newImportInfo);
getImportSet().add(newImportInfo);
return true;
}
/**
* Returns import for class.
*
* @param attr java attribute info
* @return imports for class
*/
public List<String> getImports(JavaAttributeInfo attr) {
public List<String> getImports() {
String importString;
List<String> imports = new ArrayList<>();
......@@ -153,7 +147,7 @@ public class JavaImportData {
}
}
if (attr.isListAttr()) {
if (isListToImport) {
imports.add(getImportForList());
}
......@@ -162,29 +156,6 @@ public class JavaImportData {
}
/**
* Returns import for class.
*
* @return imports for class
*/
public List<String> getImports() {
String importString;
List<String> imports = new ArrayList<>();
for (JavaQualifiedTypeInfo importInfo : getImportSet()) {
if (!importInfo.getPkgInfo().equals(EMPTY_STRING) && importInfo.getClassInfo() != null
&& !importInfo.getPkgInfo().equals(JAVA_LANG)) {
importString = IMPORT + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN
+ NEW_LINE;
imports.add(importString);
}
}
sort(imports);
return imports;
}
/**
* Returns import for hash and equals method.
*
* @return import for hash and equals method
......
......@@ -18,7 +18,7 @@ package org.onosproject.yangutils.translator.tojava;
/**
* Represents the information of the java import data.
*/
public interface HasJavaImportData {
public interface JavaImportDataContainer {
/**
* Returns the data of java imports to be included in generated file.
......
......@@ -17,10 +17,12 @@
package org.onosproject.yangutils.translator.tojava;
import java.util.Objects;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer;
import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType;
import com.google.common.base.MoreObjects;
import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportClass;
......@@ -29,8 +31,8 @@ import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDa
/**
* Represents the information about individual imports in the generated file.
*/
public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> {
public class JavaQualifiedTypeInfo
implements Comparable<JavaQualifiedTypeInfo> {
/**
* Package location where the imported class/interface is defined.
*/
......@@ -84,40 +86,31 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo>
}
/**
* Returns the import info for an attribute, which needs to be used for code
* generation for import or for qualified access.
* Updates the leaf's java information.
*
* @param curNode current data model node for which the java file is being
* generated
* @param attrType type of attribute being added, it will be null, when the
* child class is added as an attribute
* @param attributeName name of the attribute being added, it will used in
* import info for child class
* @param isListAttr is the added attribute going to be used as a list
* @return return the import info for this attribute
* @param leaf leaf whose jave information is being updated
*/
public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfAttribute(YangNode curNode,
YangType<?> attrType, String attributeName,
boolean isListAttr) {
public static void updateLeavesJavaQualifiedInfo(JavaLeafInfoContainer leaf) {
JavaQualifiedTypeInfo importInfo = new JavaQualifiedTypeInfo();
JavaQualifiedTypeInfo importInfo = leaf.getJavaQualifiedInfo();
if (attrType == null) {
throw new TranslatorException("missing data type of leaf " + attributeName);
if (leaf.getDataType() == null) {
throw new TranslatorException("missing data type of leaf " + leaf.getName());
}
/*
* Current leaves holder is adding a leaf info as a attribute to the
* current class.
*/
String className = getJavaImportClass(attrType, isListAttr);
String className = AttributesJavaDataType.getJavaImportClass(leaf.getDataType(), leaf.isLeafList());
if (className != null) {
/*
* Corresponding to the attribute type a class needs to be imported,
* since it can be a derived type or a usage of wrapper classes.
*/
importInfo.setClassInfo(className);
String classPkg = getJavaImportPackage(attrType, isListAttr, className);
String classPkg = AttributesJavaDataType.getJavaImportPackage(leaf.getDataType(),
leaf.isLeafList(), className);
if (classPkg == null) {
throw new TranslatorException("import package cannot be null when the class is used");
}
......@@ -127,32 +120,30 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo>
* The attribute does not need a class to be imported, for example
* built in java types.
*/
String dataTypeName = AttributesJavaDataType.getJavaDataType(attrType);
String dataTypeName = AttributesJavaDataType.getJavaDataType(leaf.getDataType());
if (dataTypeName == null) {
throw new TranslatorException("not supported data type");
}
importInfo.setClassInfo(dataTypeName);
}
return importInfo;
}
/**
* Returns the import info for an attribute, which needs to be used for code
* generation for import or for qualified access.
*
* @param curNode current data model node for which the java file is being
* generated
* @param curNode current data model node for which the java file is being
* generated
* @param attributeName name of the attribute being added, it will used in
* import info for child class
* @param isListAttr is the added attribute going to be used as a list
* import info for child class
* @return return the import info for this attribute
*/
public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfCurNode(YangNode curNode,
String attributeName, boolean isListAttr) {
String attributeName) {
JavaQualifiedTypeInfo importInfo = new JavaQualifiedTypeInfo();
if (!(curNode instanceof HasJavaFileInfo)) {
if (!(curNode instanceof JavaFileInfoContainer)) {
throw new TranslatorException("missing java file information to get the package details "
+ "of attribute corresponding to child node");
}
......@@ -162,8 +153,8 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo>
* classes package with current classes name.
*/
importInfo.setClassInfo(attributeName);
importInfo.setPkgInfo((((HasJavaFileInfo) curNode).getJavaFileInfo().getPackage() + "."
+ ((HasJavaFileInfo) curNode).getJavaFileInfo().getJavaName()).toLowerCase());
importInfo.setPkgInfo((((JavaFileInfoContainer) curNode).getJavaFileInfo().getPackage() + "."
+ ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()).toLowerCase());
return importInfo;
}
......@@ -187,82 +178,6 @@ public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo>
return qualifiedInfoOfFromString;
}
/**
* Returns if the attribute needs to be accessed in a qualified manner or not,
* if it needs to be imported, then the same needs to be done.
*
* @param curNode current cache of the data model node for which java file
* is bing generated
* @param importInfo import info for the current attribute being added
* @return status of the qualified access to the attribute
*/
public static boolean getIsQualifiedAccessOrAddToImportList(YangNode curNode,
JavaQualifiedTypeInfo importInfo) {
boolean isImportPkgEqualCurNodePkg;
if (!(curNode instanceof HasJavaFileInfo)) {
throw new TranslatorException("missing java file info for getting the qualified access");
}
if (importInfo.getClassInfo().contentEquals(
((HasJavaFileInfo) curNode).getJavaFileInfo().getJavaName())) {
/*
* if the current class name is same as the attribute class name,
* then the attribute must be accessed in a qualified manner.
*/
return true;
} else if (importInfo.getPkgInfo() != null) {
/*
* If the attribute type is having the package info, it is contender
* for import list and also need to check if it needs to be a
* qualified access.
*/
isImportPkgEqualCurNodePkg = isImportPkgEqualCurNodePkg(curNode, importInfo);
if (!isImportPkgEqualCurNodePkg) {
/*
* If the package of the attribute added is not same as the
* current class package, then it must either be imported for
* access or it must be a qualified access.
*/
if (!(curNode instanceof HasJavaImportData)) {
/*
* If the current data model node is not supposed to import
* data, then this is a usage issue and needs to be fixed.
*/
throw new TranslatorException("Current node needs to support Imports");
}
boolean isImportAdded = ((HasJavaImportData) curNode).getJavaImportData()
.addImportInfo(curNode, importInfo);
if (!isImportAdded) {
/*
* If the attribute type info is not imported, then it must
* be a qualified access.
*/
return true;
}
}
}
return false;
}
/**
* Checks if the import info is same as the package of the current generated
* java file.
*
* @param curNode Java identifier of the current data model node
* @param importInfo import info for an attribute
* @return true if the import info is same as the current nodes package
* false otherwise
*/
public static boolean isImportPkgEqualCurNodePkg(
YangNode curNode, JavaQualifiedTypeInfo importInfo) {
if (!(curNode instanceof HasJavaFileInfo)) {
throw new TranslatorException("missing java file info for the data model node");
}
return ((HasJavaFileInfo) curNode).getJavaFileInfo().getPackage()
.contentEquals(importInfo.getPkgInfo());
}
@Override
public int hashCode() {
......
......@@ -18,7 +18,7 @@ package org.onosproject.yangutils.translator.tojava;
/**
* Maintain the java qualified access details for an attribute or a class.
*/
public interface HasJavaQualifiedTypeInfo {
public interface JavaQualifiedTypeInfoContainer {
/**
* Obtain the java qualified details.
......
/*
* 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.translator.tojava;
import java.io.IOException;
/**
* Represents implementation of java bean code fragments temporary implementations.
*/
public class TempJavaBeanFragmentFiles
extends TempJavaFragmentFiles {
/**
* Creates an instance of temporary java code fragment.
*
* @param javaFileInfo generated java file info
* @throws IOException when fails to create new file handle
*/
public TempJavaBeanFragmentFiles(JavaFileInfo javaFileInfo)
throws IOException {
super(javaFileInfo);
}
}
......@@ -18,7 +18,7 @@ package org.onosproject.yangutils.translator.tojava;
/**
* Represents Has temporary file handle.
*/
public interface HasTempJavaCodeFragmentFiles {
public interface TempJavaCodeFragmentFilesContainer {
/**
* Returns the temporary file handle.
......
/*
* 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.translator.tojava;
import java.io.IOException;
/**
* Represents implementation of java code fragments temporary implementations.
*/
public class TempJavaEnumerationFragmentFiles
extends TempJavaFragmentFiles {
/**
* Creates an instance of temporary java code fragment.
*
* @param javaFileInfo generated java file info
* @throws IOException when fails to create new file handle
*/
public TempJavaEnumerationFragmentFiles(JavaFileInfo javaFileInfo)
throws IOException {
super(javaFileInfo);
}
}
/*
* 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.translator.tojava;
import java.io.IOException;
/**
* Represents implementation of java service code fragments temporary implementations.
*/
public class TempJavaServiceFragmentFiles
extends TempJavaFragmentFiles {
/**
* Creates an instance of temporary java code fragment.
*
* @param javaFileInfo generated file information
* @throws IOException when fails to create new file handle
*/
public TempJavaServiceFragmentFiles(JavaFileInfo javaFileInfo)
throws IOException {
super(javaFileInfo);
}
}
/*
* 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.translator.tojava;
import java.io.IOException;
/**
* Represents implementation of java data type code fragments temporary implementations.
*/
public class TempJavaTypeFragmentFiles
extends TempJavaFragmentFiles {
/**
* Creates an instance of temporary java code fragment.
*
* @param javaFileInfo generated java file info
* @throws IOException when fails to create new file handle
*/
public TempJavaTypeFragmentFiles(JavaFileInfo javaFileInfo)
throws IOException {
super(javaFileInfo);
}
}
......@@ -16,9 +16,8 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
/**
* Represents YANG java info containing interface for java code generator, java
......@@ -26,5 +25,6 @@ import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
* interface serves as a generic interface and help to unify the generate code
* entry function.
*/
public interface JavaCodeGeneratorInfo extends HasJavaFileInfo, HasTempJavaCodeFragmentFiles, HasJavaImportData {
public interface JavaCodeGeneratorInfo
extends JavaFileInfoContainer, TempJavaCodeFragmentFilesContainer {
}
......
/*
* 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.translator.tojava.javamodel;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer;
import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil;
/**
* Represent java based identification of the YANG leaves.
*/
public interface JavaLeafInfoContainer
extends JavaQualifiedTypeInfoContainer {
/**
* Retreives the data type of the leaf.
*
* @return data type of the leaf
*/
YangType<?> getDataType();
/**
* Retreives the name of the leaf.
*
* @return name of the leaf
*/
String getName();
/**
* Retreives the java name of the leaf.
*
* @param conflictResolveConfig user config to resolve conflicts
* @return name of the leaf
*/
String getJavaName(YangToJavaNamingConflictUtil conflictResolveConfig);
/**
* Identifies if object is a leaf-list.
*
* @return true if leaf-list false otherwise
*/
boolean isLeafList();
/**
* updates the qualified info.
*/
void updateJavaQualifiedInfo();
}
/*
* 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.translator.tojava.javamodel;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfoContainer;
/**
* Represent java based identification of the YANG leaves.
*/
public interface JavaQualifiedTypeResolver
extends JavaQualifiedTypeInfoContainer {
/**
* updates the qualified access details of the type.
*/
void updateJavaQualifiedInfo();
}
......@@ -21,17 +21,18 @@ import org.onosproject.yangutils.datamodel.YangAugment;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode;
/**
* Represents augment information extended to support java code generation.
*/
public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInfo, JavaCodeGenerator {
public class YangJavaAugment
extends YangAugment
implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
......@@ -39,12 +40,6 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -56,7 +51,6 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf
public YangJavaAugment() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
}
......@@ -85,27 +79,6 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -133,8 +106,9 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf
* @throws IOException IO operation fail
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
generateCodeOfNode(this, yangPlugin, false);
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
generateCodeOfAugmentableNode(this, yangPlugin);
}
/**
......@@ -143,7 +117,8 @@ public class YangJavaAugment extends YangAugment implements JavaCodeGeneratorInf
* @throws IOException when failed to do IO operations
*/
@Override
public void generateCodeExit() throws IOException {
public void generateCodeExit()
throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
}
}
......
......@@ -16,21 +16,23 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangCase;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfAugmentableNode;
/**
* Represents case information extended to support java code generation.
*/
public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, JavaCodeGenerator {
public class YangJavaCase
extends YangCase
implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
......@@ -38,12 +40,6 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -55,7 +51,6 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav
public YangJavaCase() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
}
......@@ -83,27 +78,6 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -131,15 +105,17 @@ public class YangJavaCase extends YangCase implements JavaCodeGeneratorInfo, Jav
* @throws IOException IO operation fail
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
generateCodeOfNode(this, yangPlugin, false);
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
generateCodeOfAugmentableNode(this, yangPlugin);
}
/**
* Creates a java file using the YANG case info.
*/
@Override
public void generateCodeExit() throws IOException {
public void generateCodeExit()
throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
}
}
......
......@@ -16,21 +16,23 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangChoice;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents choice information extended to support java code generation.
*/
public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo, JavaCodeGenerator {
public class YangJavaChoice
extends YangChoice
implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
......@@ -38,12 +40,6 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo,
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -55,7 +51,6 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo,
public YangJavaChoice() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(INTERFACE_MASK);
}
......@@ -83,27 +78,6 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo,
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -131,15 +105,17 @@ public class YangJavaChoice extends YangChoice implements JavaCodeGeneratorInfo,
* @throws IOException IO operation fail
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
generateCodeOfNode(this, yangPlugin, false);
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
YangJavaModelUtils.generateCodeAndUpdateInParent(this, yangPlugin, false);
}
/**
* Creates a java file using the YANG choice info.
*/
@Override
public void generateCodeExit() throws IOException {
public void generateCodeExit()
throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(INTERFACE_MASK, this);
}
}
......
......@@ -16,21 +16,23 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeAndUpdateInParent;
/**
* Represents container information extended to support java code generation.
*/
public class YangJavaContainer extends YangContainer implements JavaCodeGeneratorInfo, JavaCodeGenerator {
public class YangJavaContainer
extends YangContainer
implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
......@@ -38,12 +40,6 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -55,7 +51,6 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato
public YangJavaContainer() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
}
......@@ -83,27 +78,6 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -131,8 +105,9 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato
* @throws IOException IO operation fail
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
generateCodeOfNode(this, yangPlugin, false);
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
generateCodeAndUpdateInParent(this, yangPlugin, false);
}
/**
......@@ -141,7 +116,8 @@ public class YangJavaContainer extends YangContainer implements JavaCodeGenerato
* @throws IOException IO operation fail
*/
@Override
public void generateCodeExit() throws IOException {
public void generateCodeExit()
throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
}
......
......@@ -17,11 +17,11 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangEnumeration;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
......@@ -31,7 +31,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti
/**
* Represents YANG java enumeration information extended to support java code generation.
*/
public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGenerator, JavaCodeGeneratorInfo {
public class YangJavaEnumeration
extends YangEnumeration
implements JavaCodeGenerator, JavaCodeGeneratorInfo {
/**
* Contains the information of the java file being generated.
......@@ -39,12 +41,6 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -56,7 +52,6 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene
public YangJavaEnumeration() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_ENUM_CLASS);
}
......@@ -86,29 +81,6 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -138,7 +110,8 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene
* @throws IOException IO operations fails
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
generateCodeOfNode(this, yangPlugin);
}
......@@ -148,7 +121,8 @@ public class YangJavaEnumeration extends YangEnumeration implements JavaCodeGene
* @throws IOException IO operation fail
*/
@Override
public void generateCodeExit() throws IOException {
public void generateCodeExit()
throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_ENUM_CLASS, this);
}
......
......@@ -16,131 +16,34 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangGrouping;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
/**
* Represents grouping information extended to support java code generation.
*/
public class YangJavaGrouping extends YangGrouping implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
*/
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
private TempJavaCodeFragmentFiles tempFileHandle;
public class YangJavaGrouping
extends YangGrouping
implements JavaCodeGenerator {
/**
* Creates YANG java grouping object.
* Creates YANG Java grouping object.
*/
public YangJavaGrouping() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
}
/**
* Returns the generated java file information.
*
* @return generated java file information
*/
@Override
public JavaFileInfo getJavaFileInfo() {
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node");
}
return javaFileInfo;
}
/**
* Sets the java file info object.
*
* @param javaInfo java file info object
*/
@Override
public void setJavaFileInfo(JavaFileInfo javaInfo) {
javaFileInfo = javaInfo;
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
*/
@Override
public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() {
return tempFileHandle;
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
/*Do nothing, the uses will copy the contents to the used location*/
}
/**
* Sets temporary file handle.
*
* @param fileHandle temporary file handle
*/
@Override
public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) {
tempFileHandle = fileHandle;
}
/**
* Prepare the information for java code generation corresponding to YANG
* grouping info.
*
* @param yangPlugin YANG plugin config
* @throws IOException IO operation fail
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
generateCodeOfNode(this, yangPlugin, false);
}
/**
* Creates a java file using the YANG grouping info.
*/
@Override
public void generateCodeExit() {
// TODO Auto-generated method stub
public void generateCodeExit()
throws IOException {
/*Do nothing, the uses will copy the contents to the used location*/
}
}
......
......@@ -17,11 +17,11 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangInput;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
......@@ -31,7 +31,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti
/**
* Represents input information extended to support java code generation.
*/
public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, JavaCodeGenerator {
public class YangJavaInput
extends YangInput
implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains information of the java file being generated.
......@@ -39,12 +41,6 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -56,7 +52,6 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J
public YangJavaInput() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
}
......@@ -84,27 +79,6 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -132,7 +106,8 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J
* @throws IOException IO operation fail
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
generateCodeOfNode(this, yangPlugin);
}
......@@ -142,7 +117,8 @@ public class YangJavaInput extends YangInput implements JavaCodeGeneratorInfo, J
* @throws IOException IO operation fail
*/
@Override
public void generateCodeExit() throws IOException {
public void generateCodeExit()
throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
}
}
......
/*
* Copyright 2016 Open Networking Laboratory
* 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.
......@@ -16,19 +16,23 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.translator.tojava.HasJavaQualifiedTypeInfo;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil;
import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.updateLeavesJavaQualifiedInfo;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
/**
* Maintains java information corresponding to the YANG leaf.
* Represents java information corresponding to the YANG leaf.
*/
public class YangJavaLeaf extends YangLeaf
implements HasJavaQualifiedTypeInfo {
public class YangJavaLeaf
extends YangLeaf
implements JavaLeafInfoContainer {
private JavaQualifiedTypeInfo javaQualifiedAccess;
/**
* Create a YANG leaf object with java qualified access details.
* Returns a new YANG leaf object with java qualified access details.
*/
public YangJavaLeaf() {
super();
......@@ -46,4 +50,17 @@ public class YangJavaLeaf extends YangLeaf
}
public String getJavaName(YangToJavaNamingConflictUtil conflictResolveConfig) {
return getCamelCase(getName(), conflictResolveConfig);
}
@Override
public boolean isLeafList() {
return false;
}
@Override
public void updateJavaQualifiedInfo() {
updateLeavesJavaQualifiedInfo(this);
}
}
......
/*
* 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.translator.tojava.javamodel;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
import org.onosproject.yangutils.translator.tojava.utils.YangToJavaNamingConflictUtil;
import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.updateLeavesJavaQualifiedInfo;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
/**
* Represents java information corresponding to the YANG leaf-list.
*/
public class YangJavaLeafList
extends YangLeafList
implements JavaLeafInfoContainer {
private JavaQualifiedTypeInfo javaQualifiedAccess;
/**
* Returns a new YANG leaf object with java qualified access details.
*/
public YangJavaLeafList() {
super();
setJavaQualifiedInfo(new JavaQualifiedTypeInfo());
}
@Override
public String getJavaName(YangToJavaNamingConflictUtil conflictResolveConfig) {
return getCamelCase(getName(), conflictResolveConfig);
}
@Override
public boolean isLeafList() {
return true;
}
@Override
public void updateJavaQualifiedInfo() {
updateLeavesJavaQualifiedInfo(this);
}
@Override
public JavaQualifiedTypeInfo getJavaQualifiedInfo() {
return javaQualifiedAccess;
}
@Override
public void setJavaQualifiedInfo(JavaQualifiedTypeInfo typeInfo) {
javaQualifiedAccess = typeInfo;
}
}
......@@ -16,21 +16,23 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeAndUpdateInParent;
/**
* Represents YANG list information extended to support java code generation.
*/
public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, JavaCodeGenerator {
public class YangJavaList
extends YangList
implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
......@@ -38,12 +40,6 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -55,7 +51,6 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav
public YangJavaList() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
}
......@@ -83,27 +78,6 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -131,8 +105,9 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav
* @throws IOException IO operation fail
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
generateCodeOfNode(this, yangPlugin, true);
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
generateCodeAndUpdateInParent(this, yangPlugin, true);
}
/**
......@@ -141,7 +116,8 @@ public class YangJavaList extends YangList implements JavaCodeGeneratorInfo, Jav
* @throws IOException IO operation fail
*/
@Override
public void generateCodeExit() throws IOException {
public void generateCodeExit()
throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
}
}
......
......@@ -16,22 +16,25 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_MANAGER_WITH_RPC;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
/**
* Represents module information extended to support java code generation.
*/
public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo, JavaCodeGenerator {
public class YangJavaModule
extends YangModule
implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
......@@ -39,12 +42,6 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo,
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -56,7 +53,6 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo,
public YangJavaModule() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_MANAGER_WITH_RPC);
}
......@@ -84,27 +80,6 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo,
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -131,7 +106,8 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo,
* @throws IOException when fails to generate the source files
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
String modulePkg = getRootPackage(getVersion(), getNameSpace().getUri(), getRevision().getRevDate());
YangJavaModelUtils.generateCodeOfRootNode(this, yangPlugin, modulePkg);
}
......@@ -140,7 +116,8 @@ public class YangJavaModule extends YangModule implements JavaCodeGeneratorInfo,
* Creates a java file using the YANG module info.
*/
@Override
public void generateCodeExit() throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_MANAGER_WITH_RPC, this);
public void generateCodeExit()
throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
}
}
......
......@@ -20,28 +20,19 @@ import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangNotification;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
/**
* Represents notification information extended to support java code generation.
*/
public class YangJavaNotification extends YangNotification
implements JavaCodeGenerator, HasJavaFileInfo,
HasJavaImportData, HasTempJavaCodeFragmentFiles {
public class YangJavaNotification
extends YangNotification
implements JavaCodeGenerator, JavaCodeGeneratorInfo {
/**
* Contains information of the java file being generated.
......@@ -49,12 +40,6 @@ public class YangJavaNotification extends YangNotification
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -66,7 +51,6 @@ public class YangJavaNotification extends YangNotification
public YangJavaNotification() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
}
......@@ -95,27 +79,6 @@ public class YangJavaNotification extends YangNotification
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -143,25 +106,10 @@ public class YangJavaNotification extends YangNotification
* @throws IOException IO operation fail
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName(), yangPlugin.getConflictResolver())));
getJavaFileInfo().setPackage(getCurNodePackage(this));
getJavaFileInfo().setPackageFilePath(
getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
getJavaFileInfo().setBaseCodeGenPath(yangPlugin.getCodeGenDir());
String absolutePath = getAbsolutePackagePath(
getJavaFileInfo().getBaseCodeGenPath(),
getJavaFileInfo().getPackageFilePath());
setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
getJavaFileInfo().getGeneratedFileTypes(), absolutePath,
getJavaFileInfo().getJavaName()));
getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
//TODO: implement the event listener for notifications.
}
/**
......
......@@ -17,11 +17,11 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangOutput;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
......@@ -31,7 +31,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti
/**
* Represents output information extended to support java code generation.
*/
public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo, JavaCodeGenerator {
public class YangJavaOutput
extends YangOutput
implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains information of the java file being generated.
......@@ -39,12 +41,6 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo,
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -56,7 +52,6 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo,
public YangJavaOutput() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
}
......@@ -84,27 +79,6 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo,
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -132,8 +106,10 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo,
* @throws IOException IO operation fail
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
generateCodeOfNode(this, yangPlugin);
}
/**
......@@ -142,7 +118,8 @@ public class YangJavaOutput extends YangOutput implements JavaCodeGeneratorInfo,
* @throws IOException IO operation fail
*/
@Override
public void generateCodeExit() throws IOException {
public void generateCodeExit()
throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
}
}
......
......@@ -17,27 +17,31 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.HasRpcNotification;
import org.onosproject.yangutils.datamodel.RpcNotificationContainer;
import org.onosproject.yangutils.datamodel.YangInput;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangOutput;
import org.onosproject.yangutils.datamodel.YangRpc;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getCurNodeAsAttributeInParent;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_RPC_INTERFACE;
import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.getCurNodeAsAttributeInParent;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getParentNodeInGenCode;
import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo;
/**
* Represents rpc information extended to support java code generation.
*/
public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFileInfo {
public class YangJavaRpc
extends YangRpc
implements JavaCodeGenerator, JavaCodeGeneratorInfo {
/**
* Contains the information of the java file being generated.
......@@ -45,35 +49,57 @@ public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFi
private JavaFileInfo javaFileInfo;
/**
* Temproary file for code generation.
*/
private TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles;
/**
* Creates an instance of YANG java rpc.
*/
public YangJavaRpc() {
super();
setJavaFileInfo(new JavaFileInfo());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_RPC_INTERFACE);
try {
setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(getJavaFileInfo()));
} catch (IOException e) {
throw new RuntimeException("Failed to create temporary RPC file handle");
}
}
/**
* Prepares the information for java code generation corresponding to YANG
* rpc info.
* RPC info.
*
* @param yangPlugin YANG plugin config
* @throws IOException IO operations fails
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
if (!(this instanceof YangNode)) {
if (!(this instanceof JavaCodeGeneratorInfo)) {
// TODO:throw exception
}
// Add package information for rpc and create corresponding folder.
updatePackageInfo(this, yangPlugin);
updatePackageInfo((JavaCodeGeneratorInfo) this, yangPlugin);
}
/**
* Creates a java file using the YANG RPC info.
*
* @throws IOException IO operations fails
*/
@Override
public void generateCodeExit()
throws IOException {
// Get the parent module/sub-module.
YangNode parent = getParentNodeInGenCode((YangNode) this);
// Parent should be holder of rpc or notification.
if (!(parent instanceof HasRpcNotification)) {
if (!(parent instanceof RpcNotificationContainer)) {
throw new TranslatorException("parent node of rpc can only be module or sub-module");
}
......@@ -89,35 +115,26 @@ public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFi
YangNode yangNode = this.getChild();
while (yangNode != null) {
if (yangNode instanceof YangInput) {
javaAttributeInfoOfInput = getCurNodeAsAttributeInParent(parent, false, yangNode.getName());
javaAttributeInfoOfInput = getCurNodeAsAttributeInParent(yangNode, this, false);
} else if (yangNode instanceof YangOutput) {
javaAttributeInfoOfOutput = getCurNodeAsAttributeInParent(parent, false, yangNode.getName());
javaAttributeInfoOfOutput = getCurNodeAsAttributeInParent(yangNode, this, false);
} else {
// TODO throw exception
}
yangNode = yangNode.getNextSibling();
}
if (!(parent instanceof HasTempJavaCodeFragmentFiles)) {
if (!(parent instanceof TempJavaCodeFragmentFilesContainer)) {
throw new TranslatorException("missing parent temp file handle");
}
/*
* Add the rpc information to the parent's service temp file.
*/
((HasTempJavaCodeFragmentFiles) parent)
.getTempJavaCodeFragmentFiles()
((TempJavaCodeFragmentFilesContainer) parent)
.getTempJavaCodeFragmentFiles().getServiceTempFiles()
.addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfoOfInput, javaAttributeInfoOfOutput,
((YangNode) this).getName());
}
/**
* Creates a java file using the YANG rpc info.
*
* @throws IOException IO operations fails
*/
@Override
public void generateCodeExit() throws IOException {
// No file will be generated during RPC exit.
}
......@@ -144,5 +161,15 @@ public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFi
public void setJavaFileInfo(JavaFileInfo javaInfo) {
javaFileInfo = javaInfo;
}
@Override
public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() {
return tempJavaCodeFragmentFiles;
}
@Override
public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) {
tempJavaCodeFragmentFiles = fileHandle;
}
}
......
......@@ -16,12 +16,12 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangBelongsTo;
import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
......@@ -32,7 +32,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSy
/**
* Represents sub module information extended to support java code generation.
*/
public class YangJavaSubModule extends YangSubModule implements JavaCodeGeneratorInfo, JavaCodeGenerator {
public class YangJavaSubModule
extends YangSubModule
implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
......@@ -40,12 +42,6 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -57,7 +53,6 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato
public YangJavaSubModule() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_MANAGER_WITH_RPC);
}
......@@ -85,27 +80,6 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -129,7 +103,7 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato
* Returns the name space of the module to which the sub module belongs to.
*
* @param belongsToInfo Information of the module to which the sub module
* belongs
* belongs
* @return the name space string of the module.
*/
private String getNameSpaceFromModule(YangBelongsTo belongsToInfo) {
......@@ -145,7 +119,8 @@ public class YangJavaSubModule extends YangSubModule implements JavaCodeGenerato
* @throws IOException IO operation fail
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
String subModulePkg = getRootPackage(getVersion(), getNameSpaceFromModule(getBelongsTo()),
getRevision().getRevDate());
YangJavaModelUtils.generateCodeOfRootNode(this, yangPlugin, subModulePkg);
......
/*
* 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.translator.tojava.javamodel;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType;
/**
* Represents java information corresponding to the YANG type.
*/
public class YangJavaType<T>
extends YangType<T>
implements JavaQualifiedTypeResolver {
private JavaQualifiedTypeInfo javaQualifiedAccess;
/**
* Create a YANG leaf object with java qualified access details.
*/
public YangJavaType() {
super();
setJavaQualifiedInfo(new JavaQualifiedTypeInfo());
}
@Override
public void updateJavaQualifiedInfo() {
JavaQualifiedTypeInfo importInfo = getJavaQualifiedInfo();
/*
* Type is added as an attribute in the class.
*/
String className = AttributesJavaDataType.getJavaImportClass(this, false);
if (className != null) {
/*
* Corresponding to the attribute type a class needs to be imported,
* since it can be a derived type or a usage of wrapper classes.
*/
importInfo.setClassInfo(className);
String classPkg = AttributesJavaDataType.getJavaImportPackage(this,
false, className);
if (classPkg == null) {
throw new TranslatorException("import package cannot be null when the class is used");
}
importInfo.setPkgInfo(classPkg);
} else {
/*
* The attribute does not need a class to be imported, for example
* built in java types.
*/
String dataTypeName = AttributesJavaDataType.getJavaDataType(this);
if (dataTypeName == null) {
throw new TranslatorException("not supported data type");
}
importInfo.setClassInfo(dataTypeName);
}
}
@Override
public JavaQualifiedTypeInfo getJavaQualifiedInfo() {
return javaQualifiedAccess;
}
@Override
public void setJavaQualifiedInfo(JavaQualifiedTypeInfo typeInfo) {
javaQualifiedAccess = typeInfo;
}
}
......@@ -16,11 +16,11 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
......@@ -30,7 +30,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti
/**
* Represents type define information extended to support java code generation.
*/
public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInfo, JavaCodeGenerator {
public class YangJavaTypeDef
extends YangTypeDef
implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
......@@ -38,12 +40,6 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -55,7 +51,6 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf
public YangJavaTypeDef() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_TYPEDEF_CLASS);
}
......@@ -84,27 +79,6 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -132,8 +106,9 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf
* @throws IOException IO operations fails
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
generateCodeOfNode(this, yangPlugin, false);
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
generateCodeOfNode(this, yangPlugin);
}
/**
......@@ -142,7 +117,8 @@ public class YangJavaTypeDef extends YangTypeDef implements JavaCodeGeneratorInf
* @throws IOException IO operations fails
*/
@Override
public void generateCodeExit() throws IOException {
public void generateCodeExit()
throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_TYPEDEF_CLASS, this);
}
......
......@@ -16,10 +16,10 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import java.io.IOException;
import org.onosproject.yangutils.datamodel.YangUnion;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
......@@ -29,7 +29,9 @@ import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUti
/**
* Represents union information extended to support java code generation.
*/
public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, JavaCodeGenerator {
public class YangJavaUnion
extends YangUnion
implements JavaCodeGeneratorInfo, JavaCodeGenerator {
/**
* Contains the information of the java file being generated.
......@@ -37,12 +39,6 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
/**
* File handle to maintain temporary java code fragments as per the code
* snippet types.
*/
......@@ -54,7 +50,6 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J
public YangJavaUnion() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_UNION_CLASS);
}
......@@ -82,27 +77,6 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
* Returns the temporary file handle.
*
* @return temporary file handle
......@@ -134,7 +108,8 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J
* @throws IOException IO operations fails
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
public void generateCodeEntry(YangPluginConfig yangPlugin)
throws IOException {
generateCodeOfNode(this, yangPlugin);
}
......@@ -144,7 +119,8 @@ public class YangJavaUnion extends YangUnion implements JavaCodeGeneratorInfo, J
* @throws IOException IO operations fails
*/
@Override
public void generateCodeExit() throws IOException {
public void generateCodeExit()
throws IOException {
getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_UNION_CLASS, this);
}
}
......
......@@ -16,89 +16,21 @@
package org.onosproject.yangutils.translator.tojava.javamodel;
import org.onosproject.yangutils.datamodel.YangUses;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaImportData;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
/**
* Represents uses information extended to support java code generation.
*/
public class YangJavaUses extends YangUses implements JavaCodeGenerator, HasJavaFileInfo, HasJavaImportData {
/**
* Contains the information of the java file being generated.
*/
private JavaFileInfo javaFileInfo;
/**
* Contains information of the imports to be inserted in the java file
* generated.
*/
private JavaImportData javaImportData;
public class YangJavaUses
extends YangUses
implements JavaCodeGenerator {
/**
* Creates YANG java uses object.
*/
public YangJavaUses() {
super();
setJavaFileInfo(new JavaFileInfo());
setJavaImportData(new JavaImportData());
getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
}
/**
* Returns the generated java file information.
*
* @return generated java file information
*/
@Override
public JavaFileInfo getJavaFileInfo() {
if (javaFileInfo == null) {
throw new TranslatorException("Missing java info in java datamodel node");
}
return javaFileInfo;
}
/**
* Sets the java file info object.
*
* @param javaInfo java file info object
*/
@Override
public void setJavaFileInfo(JavaFileInfo javaInfo) {
javaFileInfo = javaInfo;
}
/**
* Returns the data of java imports to be included in generated file.
*
* @return data of java imports to be included in generated file
*/
@Override
public JavaImportData getJavaImportData() {
return javaImportData;
}
/**
* Sets the data of java imports to be included in generated file.
*
* @param javaImportData data of java imports to be included in generated
* file
*/
@Override
public void setJavaImportData(JavaImportData javaImportData) {
this.javaImportData = javaImportData;
}
/**
......@@ -109,14 +41,7 @@ public class YangJavaUses extends YangUses implements JavaCodeGenerator, HasJava
*/
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin) {
getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName(), yangPlugin.getConflictResolver())));
getJavaFileInfo().setPackage(getCurNodePackage(this));
getJavaFileInfo().setPackageFilePath(
getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
getJavaFileInfo().setBaseCodeGenPath(yangPlugin.getCodeGenDir());
//TODO:addCurNodeLeavesInfoToTempFiles(this);
//TODO:addCurNodeInfoInParentTempFile(this, false);
/*Do nothing, the uses will copy the contents to the used location*/
}
/**
......@@ -124,7 +49,6 @@ public class YangJavaUses extends YangUses implements JavaCodeGenerator, HasJava
*/
@Override
public void generateCodeExit() {
// TODO Auto-generated method stub
/*Do nothing, the uses will copy the contents to the used location*/
}
}
......
......@@ -24,7 +24,7 @@ import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.datamodel.YangUnion;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration;
import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaTypeDef;
......@@ -109,7 +109,7 @@ public final class AttributesJavaDataType {
* Returns from string method parsed string.
*
* @param targetDataType target data type
* @param yangType YANG type
* @param yangType YANG type
* @return parsed string
*/
public static String getParseFromStringMethod(String targetDataType, YangType<?> yangType) {
......@@ -155,7 +155,7 @@ public final class AttributesJavaDataType {
/**
* Returns java import class.
*
* @param yangType YANG type
* @param yangType YANG type
* @param isListAttr if the attribute need to be a list
* @return java import class
*/
......@@ -183,6 +183,7 @@ public final class AttributesJavaDataType {
return BIG_INTEGER;
case DECIMAL64:
//TODO: DECIMAL64.
break;
case STRING:
return STRING_DATA_TYPE;
case BOOLEAN:
......@@ -192,12 +193,16 @@ public final class AttributesJavaDataType {
getCamelCase(((YangJavaEnumeration) yangType.getDataTypeExtendedInfo()).getName(), null));
case BITS:
//TODO:BITS
break;
case BINARY:
//TODO:BINARY
break;
case LEAFREF:
//TODO:LEAFREF
break;
case IDENTITYREF:
//TODO:IDENTITYREF
break;
case EMPTY:
return BOOLEAN_WRAPPER;
case UNION:
......@@ -216,6 +221,7 @@ public final class AttributesJavaDataType {
return BIG_INTEGER;
case DECIMAL64:
//TODO: DECIMAL64.
break;
case STRING:
return STRING_DATA_TYPE;
case ENUMERATION:
......@@ -223,33 +229,40 @@ public final class AttributesJavaDataType {
getCamelCase(((YangJavaEnumeration) yangType.getDataTypeExtendedInfo()).getName(), null));
case BITS:
//TODO:BITS
break;
case BINARY:
//TODO:BINARY
break;
case LEAFREF:
//TODO:LEAFREF
break;
case IDENTITYREF:
//TODO:IDENTITYREF
break;
case EMPTY:
//TODO:EMPTY
break;
case UNION:
return getCaptialCase(getCamelCase(((YangJavaUnion) yangType.getDataTypeExtendedInfo()).getName(),
null));
case INSTANCE_IDENTIFIER:
//TODO:INSTANCE_IDENTIFIER
break;
case DERIVED:
return getCaptialCase(getCamelCase(yangType.getDataTypeName(), null));
default:
return null;
}
}
return null;
}
/**
* Returns java import package.
*
* @param yangType YANG type
* @param yangType YANG type
* @param isListAttr if the attribute is of list type
* @param classInfo java import class info
* @param classInfo java import class info
* @return java import package
*/
public static String getJavaImportPackage(YangType<?> yangType, boolean isListAttr, String classInfo) {
......@@ -272,22 +285,29 @@ public final class AttributesJavaDataType {
return JAVA_MATH;
case DECIMAL64:
//TODO: DECIMAL64.
break;
case ENUMERATION:
return getEnumsPackage(yangType);
case BITS:
//TODO:BITS
break;
case BINARY:
//TODO:BINARY
break;
case LEAFREF:
//TODO:LEAFREF
break;
case IDENTITYREF:
//TODO:IDENTITYREF
break;
case EMPTY:
//TODO:EMPTY
break;
case UNION:
return getUnionPackage(yangType);
case INSTANCE_IDENTIFIER:
//TODO:INSTANCE_IDENTIFIER
break;
case DERIVED:
return getTypDefsPackage(yangType);
default:
......@@ -297,32 +317,41 @@ public final class AttributesJavaDataType {
switch (type) {
case UINT64:
//TODO: BIGINTEGER.
break;
case DECIMAL64:
//TODO: DECIMAL64
break;
case STRING:
return JAVA_LANG;
case ENUMERATION:
return getEnumsPackage(yangType);
case BITS:
//TODO:BITS
break;
case BINARY:
//TODO:BINARY
break;
case LEAFREF:
//TODO:LEAFREF
break;
case IDENTITYREF:
//TODO:IDENTITYREF
break;
case EMPTY:
//TODO:EMPTY
break;
case UNION:
return getUnionPackage(yangType);
case INSTANCE_IDENTIFIER:
//TODO:INSTANCE_IDENTIFIER
break;
case DERIVED:
return getTypDefsPackage(yangType);
default:
return null;
}
}
return null;
}
/**
......@@ -392,10 +421,10 @@ public final class AttributesJavaDataType {
* @return java package from parent node
*/
private static String getPackageFromParent(YangNode parent) {
if (!(parent instanceof HasJavaFileInfo)) {
if (!(parent instanceof JavaFileInfoContainer)) {
throw new TranslatorException("invalid child node is being processed.");
}
JavaFileInfo parentInfo = ((HasJavaFileInfo) parent).getJavaFileInfo();
JavaFileInfo parentInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo();
return parentInfo.getPackage() + PERIOD + parentInfo.getJavaName().toLowerCase();
}
}
......
......@@ -21,7 +21,7 @@ import java.util.List;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.translator.exception.TranslatorException;
import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
import static org.onosproject.yangutils.utils.UtilConstants.COLAN;
......@@ -111,16 +111,16 @@ public final class JavaIdentifierSyntax {
public static String getCurNodePackage(YangNode curNode) {
String pkg;
if (!(curNode instanceof HasJavaFileInfo)
if (!(curNode instanceof JavaFileInfoContainer)
|| curNode.getParent() == null) {
throw new TranslatorException("missing parent node to get current node's package");
}
YangNode parentNode = getParentNodeInGenCode(curNode);
if (!(parentNode instanceof HasJavaFileInfo)) {
if (!(parentNode instanceof JavaFileInfoContainer)) {
throw new TranslatorException("missing parent java node to get current node's package");
}
JavaFileInfo parentJavaFileHandle = ((HasJavaFileInfo) parentNode).getJavaFileInfo();
JavaFileInfo parentJavaFileHandle = ((JavaFileInfoContainer) parentNode).getJavaFileInfo();
pkg = parentJavaFileHandle.getPackage() + PERIOD + parentJavaFileHandle.getJavaName();
return pkg.toLowerCase();
}
......
......@@ -138,7 +138,7 @@ public final class MethodsGenerator {
/**
* Returns setter string.
*
* @param attr attribute info
* @param attr attribute info
* @param className java class name
* @return setter string
*/
......@@ -164,7 +164,7 @@ public final class MethodsGenerator {
/**
* Returns default constructor method string.
*
* @param name class name
* @param name class name
* @param modifierType modifier type
* @return default constructor string
*/
......@@ -228,7 +228,7 @@ public final class MethodsGenerator {
/**
* Returns the setter method strings for class file.
*
* @param attr attribute info
* @param attr attribute info
* @param className name of the class
* @return setter method for class
*/
......@@ -247,8 +247,8 @@ public final class MethodsGenerator {
* Returns setter for attribute.
*
* @param className class name
* @param name attribute name
* @param type return type
* @param name attribute name
* @param type return type
* @return setter for attribute
*/
private static String getSetter(String className, String name, String type) {
......@@ -298,9 +298,9 @@ public final class MethodsGenerator {
/**
* Returns the getter method strings for interface file.
*
* @param yangName name of the attribute
* @param yangName name of the attribute
* @param returnType return type of attribute
* @param isList is list attribute
* @param isList is list attribute
* @return getter method for interface
*/
public static String getGetterForInterface(String yangName, String returnType, boolean isList) {
......@@ -316,7 +316,7 @@ public final class MethodsGenerator {
* Returns getter for attribute in interface.
*
* @param returnType return type
* @param yangName attribute name
* @param yangName attribute name
* @return getter for interface
*/
private static String getGetterInterfaceString(String returnType, String yangName) {
......@@ -327,10 +327,10 @@ public final class MethodsGenerator {
/**
* Returns the setter method strings for interface file.
*
* @param attrName name of the attribute
* @param attrType return type of attribute
* @param attrName name of the attribute
* @param attrType return type of attribute
* @param className name of the java class being generated
* @param isList is list attribute
* @param isList is list attribute
* @return setter method for interface
*/
public static String getSetterForInterface(String attrName, String attrType, String className, boolean isList) {
......@@ -346,8 +346,8 @@ public final class MethodsGenerator {
* Returns setter string for interface.
*
* @param className class name
* @param attrName attribute name
* @param attrType attribute type
* @param attrName attribute name
* @param attrType attribute type
* @return setter string
*/
private static String getSetterInterfaceString(String className, String attrName, String attrType) {
......@@ -410,7 +410,7 @@ public final class MethodsGenerator {
* Returns the constructor strings for class file.
*
* @param yangName name of the class
* @param attr attribute info
* @param attr attribute info
* @return constructor for class
*/
public static String getConstructor(String yangName, JavaAttributeInfo attr) {
......@@ -428,8 +428,8 @@ public final class MethodsGenerator {
/**
* Returns the rpc strings for service interface.
*
* @param rpcName name of the rpc
* @param inputName name of input
* @param rpcName name of the rpc
* @param inputName name of input
* @param outputName name of output
* @return rpc method string
*/
......@@ -459,7 +459,7 @@ public final class MethodsGenerator {
/**
* Returns the Default constructor strings for class file.
*
* @param name name of the class
* @param name name of the class
* @param modifierType modifier type for default constructor
* @return Default constructor for class
*/
......@@ -536,13 +536,13 @@ public final class MethodsGenerator {
/**
* Return from string method's body string.
*
* @param attr attribute info
* @param attr attribute info
* @param fromStringAttributeInfo attribute info for the from string
* wrapper type
* wrapper type
* @return from string method's body string
*/
public static String getFromStringMethod(JavaAttributeInfo attr,
JavaAttributeInfo fromStringAttributeInfo) {
JavaAttributeInfo fromStringAttributeInfo) {
return EIGHT_SPACE_INDENTATION + getTrySubString() + NEW_LINE + TWELVE_SPACE_INDENTATION
+ getParsedSubString(attr, fromStringAttributeInfo) + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION
......@@ -585,7 +585,7 @@ public final class MethodsGenerator {
* @return sub string with parsed statement for union's from string method
*/
private static String getParsedSubString(JavaAttributeInfo attr,
JavaAttributeInfo fromStringAttributeInfo) {
JavaAttributeInfo fromStringAttributeInfo) {
String targetDataType = getReturnType(attr);
String parseFromStringMethod = getParseFromStringMethod(targetDataType,
......@@ -731,7 +731,7 @@ public final class MethodsGenerator {
/**
* Returns of method's string and java doc for special type.
*
* @param attr attribute info
* @param attr attribute info
* @param generatedJavaClassName class name
* @return of method's string and java doc for special type
*/
......@@ -747,7 +747,7 @@ public final class MethodsGenerator {
/**
* Returns of method's string.
*
* @param type data type
* @param type data type
* @param className class name
* @return of method's string
*/
......@@ -762,7 +762,7 @@ public final class MethodsGenerator {
/**
* Returns string and java doc for constructor of type class.
*
* @param attr attribute info
* @param attr attribute info
* @param generatedJavaClassName class name
* @return string and java doc for constructor of type class
*/
......@@ -778,8 +778,8 @@ public final class MethodsGenerator {
/**
* Returns type constructor string.
*
* @param type data type
* @param name attribute name
* @param type data type
* @param name attribute name
* @param className class name
* @return type constructor string
*/
......
......@@ -21,7 +21,7 @@ import java.io.IOException;
import java.util.List;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
import org.onosproject.yangutils.translator.tojava.JavaImportDataContainer;
import static org.onosproject.yangutils.translator.tojava.JavaImportData.getAugmentedInfoImport;
import static org.onosproject.yangutils.translator.tojava.JavaImportData.getHasAugmentationImport;
......@@ -52,9 +52,9 @@ public final class TempJavaCodeFragmentFilesUtils {
* @return import list
*/
public static List<String> addImportsToStringAndHasCodeMethods(YangNode curNode, List<String> imports) {
if (curNode instanceof HasJavaImportData) {
imports.add(((HasJavaImportData) curNode).getJavaImportData().getImportForHashAndEquals());
imports.add(((HasJavaImportData) curNode).getJavaImportData().getImportForToString());
if (curNode instanceof JavaImportDataContainer) {
imports.add(((JavaImportDataContainer) curNode).getJavaImportData().getImportForHashAndEquals());
imports.add(((JavaImportDataContainer) curNode).getJavaImportData().getImportForToString());
}
return imports;
}
......@@ -68,7 +68,7 @@ public final class TempJavaCodeFragmentFilesUtils {
* @return import for HasAugmentation class
*/
public static List<String> addHasAugmentationImport(YangNode curNode, List<String> imports, boolean operation) {
if (curNode instanceof HasJavaImportData) {
if (curNode instanceof JavaImportDataContainer) {
String thisImport = getHasAugmentationImport();
performOperationOnImports(imports, thisImport, operation);
}
......@@ -84,7 +84,7 @@ public final class TempJavaCodeFragmentFilesUtils {
* @return import for AugmentedInfo class
*/
public static List<String> addAugmentedInfoImport(YangNode curNode, List<String> imports, boolean operation) {
if (curNode instanceof HasJavaImportData) {
if (curNode instanceof JavaImportDataContainer) {
String thisImport = getAugmentedInfoImport();
performOperationOnImports(imports, thisImport, operation);
}
......@@ -100,7 +100,7 @@ public final class TempJavaCodeFragmentFilesUtils {
* @return import for HasAugmentation class
*/
public static List<String> addArrayListImport(YangNode curNode, List<String> imports, boolean operation) {
if (curNode instanceof HasJavaImportData) {
if (curNode instanceof JavaImportDataContainer) {
String arrayListImport = getImportForArrayList();
String listImport = getImportForList();
performOperationOnImports(imports, arrayListImport, operation);
......
......@@ -65,7 +65,7 @@ public class IntraFileTypeLinkingTest {
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
......@@ -104,7 +104,7 @@ public class IntraFileTypeLinkingTest {
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
......@@ -144,7 +144,7 @@ public class IntraFileTypeLinkingTest {
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
......@@ -184,7 +184,7 @@ public class IntraFileTypeLinkingTest {
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
......@@ -222,7 +222,7 @@ public class IntraFileTypeLinkingTest {
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
......@@ -274,7 +274,7 @@ public class IntraFileTypeLinkingTest {
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
......@@ -325,7 +325,7 @@ public class IntraFileTypeLinkingTest {
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
......@@ -377,7 +377,7 @@ public class IntraFileTypeLinkingTest {
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
......
......@@ -80,7 +80,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under grouping.
assertThat(leafInfo.getLeafName(), is("hello"));
assertThat(leafInfo.getName(), is("hello"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
......@@ -96,7 +96,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under module.
assertThat(leafInfo.getLeafName(), is("hello"));
assertThat(leafInfo.getName(), is("hello"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
......@@ -134,7 +134,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under grouping.
assertThat(leafInfo.getLeafName(), is("treat"));
assertThat(leafInfo.getName(), is("treat"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
......@@ -149,7 +149,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under container which is under grouping.
assertThat(leafInfo.getLeafName(), is("leaf2"));
assertThat(leafInfo.getName(), is("leaf2"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
......@@ -165,7 +165,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under module.
assertThat(leafInfo.getLeafName(), is("treat"));
assertThat(leafInfo.getName(), is("treat"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
......@@ -180,7 +180,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under container which is under module.
assertThat(leafInfo.getLeafName(), is("leaf2"));
assertThat(leafInfo.getName(), is("leaf2"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
}
......@@ -227,7 +227,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under list which is under grouping.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......@@ -253,7 +253,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under list which is deep copied.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......@@ -282,7 +282,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under list which is deep copied.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......@@ -353,7 +353,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under design-container.
assertThat(leafInfo.getLeafName(), is("ink"));
assertThat(leafInfo.getName(), is("ink"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("int32"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
......@@ -374,7 +374,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under correct-container.
assertThat(leafInfo.getLeafName(), is("newone"));
assertThat(leafInfo.getName(), is("newone"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
......@@ -397,7 +397,7 @@ public class IntraFileUsesLinkingTest {
// Check whether the information in the leaf is correct under container
// which has been deep copied from grouping.
assertThat(leafInfo.getLeafName(), is("zip-code"));
assertThat(leafInfo.getName(), is("zip-code"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
......@@ -426,7 +426,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under list which has been deep copied from grouping.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......@@ -441,7 +441,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under grouping.
assertThat(leafInfo.getLeafName(), is("zip-code"));
assertThat(leafInfo.getName(), is("zip-code"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
......@@ -517,7 +517,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under grouping.
assertThat(leafInfo.getLeafName(), is("carry"));
assertThat(leafInfo.getName(), is("carry"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
......@@ -550,7 +550,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under list.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
}
......@@ -687,7 +687,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under grouping.
assertThat(leafInfo.getLeafName(), is("hello"));
assertThat(leafInfo.getName(), is("hello"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
......@@ -761,7 +761,7 @@ public class IntraFileUsesLinkingTest {
leafInfo = leafIterator.next();
// Check whether the information in the leaf is correct under grouping.
assertThat(leafInfo.getLeafName(), is("hello"));
assertThat(leafInfo.getName(), is("hello"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("String"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
}
......
......@@ -62,7 +62,7 @@ public class AugmentListenerTest {
ListIterator<YangLeaf> leafIterator = yangAugment.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("ds0ChannelNumber"));
assertThat(leafInfo.getName(), is("ds0ChannelNumber"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("ChannelNumber"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
}
......
......@@ -61,7 +61,7 @@ public class BitListenerTest {
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("mybits"));
assertThat(leafInfo.getName(), is("mybits"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("bits"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.BITS));
assertThat(((YangBits) leafInfo.getDataType().getDataTypeExtendedInfo()).getBitsName(),
......
......@@ -70,7 +70,7 @@ public class CaseListenerTest {
ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator();
YangLeaf leafInfo1 = leafIterator1.next();
assertThat(leafInfo1.getLeafName(), is("pretzel"));
assertThat(leafInfo1.getName(), is("pretzel"));
YangCase yangCase2 = (YangCase) yangCase1.getNextSibling();
assertThat(yangCase2.getName(), is("late-night"));
......@@ -79,7 +79,7 @@ public class CaseListenerTest {
ListIterator<YangLeaf> leafIterator2 = yangCase2.getListOfLeaf().listIterator();
YangLeaf leafInfo2 = leafIterator2.next();
assertThat(leafInfo2.getLeafName(), is("chocolate"));
assertThat(leafInfo2.getName(), is("chocolate"));
}
/**
......@@ -140,7 +140,7 @@ public class CaseListenerTest {
ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator();
YangLeaf leafInfo1 = leafIterator1.next();
assertThat(leafInfo1.getLeafName(), is("pretzel"));
assertThat(leafInfo1.getName(), is("pretzel"));
YangChoice yangChoice2 = (YangChoice) yangChoice.getNextSibling();
assertThat(yangChoice2.getName(), is("lunch"));
......@@ -152,7 +152,7 @@ public class CaseListenerTest {
ListIterator<YangLeaf> leafIterator2 = yangCase2.getListOfLeaf().listIterator();
YangLeaf leafInfo2 = leafIterator2.next();
assertThat(leafInfo2.getLeafName(), is("chocolate"));
assertThat(leafInfo2.getName(), is("chocolate"));
}
/**
......@@ -186,7 +186,7 @@ public class CaseListenerTest {
ListIterator<YangLeaf> leafIterator1 = yangCase1.getListOfLeaf().listIterator();
YangLeaf leafInfo1 = leafIterator1.next();
assertThat(leafInfo1.getLeafName(), is("pretzel"));
assertThat(leafInfo1.getName(), is("pretzel"));
YangCase yangCase2 = (YangCase) yangCase1.getNextSibling();
assertThat(yangCase2.getName(), is("late-night"));
......@@ -200,6 +200,6 @@ public class CaseListenerTest {
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf> leafIterator2 = yangCase3.getListOfLeaf().listIterator();
YangLeaf leafInfo2 = leafIterator2.next();
assertThat(leafInfo2.getLeafName(), is("beer"));
assertThat(leafInfo2.getName(), is("beer"));
}
}
......
......@@ -68,7 +68,7 @@ public class ConfigListenerTest {
YangLeaf leafInfo = leafIterator.next();
// Check whether the Config value is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.isConfig(), is(true));
}
......@@ -94,7 +94,7 @@ public class ConfigListenerTest {
YangLeaf leafInfo = leafIterator.next();
// Check whether the Config value is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.isConfig(), is(false));
}
......@@ -168,7 +168,7 @@ public class ConfigListenerTest {
ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......@@ -204,7 +204,7 @@ public class ConfigListenerTest {
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......@@ -236,7 +236,7 @@ public class ConfigListenerTest {
YangLeafList leafListInfo = leafListIterator.next();
// Check whether config value is set correctly.
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.isConfig(), is(true));
}
......@@ -262,7 +262,7 @@ public class ConfigListenerTest {
ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.isConfig(), is(true));
}
......@@ -367,7 +367,7 @@ public class ConfigListenerTest {
YangLeafList leafListInfo = leafListIterator.next();
// Check whether config value is set correctly.
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.isConfig(), is(true));
}
......@@ -395,7 +395,7 @@ public class ConfigListenerTest {
ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.isConfig(), is(true));
}
......@@ -475,7 +475,7 @@ public class ConfigListenerTest {
YangLeafList leafListInfo = leafListIterator.next();
// Check whether config value is set correctly.
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.isConfig(), is(true));
}
......@@ -502,7 +502,7 @@ public class ConfigListenerTest {
ListIterator<YangLeaf> leafIterator = list1.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.isConfig(), is(true));
}
......@@ -531,4 +531,4 @@ public class ConfigListenerTest {
assertThat(childList.getName(), is("list1"));
assertThat(childList.isConfig(), is(true));
}
}
\ No newline at end of file
}
......
......@@ -192,7 +192,7 @@ public class ContainerListenerTest {
ListIterator<YangLeaf> leafIterator = yangContainer.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......
......@@ -68,7 +68,7 @@ public class DescriptionListenerTest {
YangLeaf leafInfo = leafIterator.next();
// Check whether the description is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
}
......@@ -176,7 +176,7 @@ public class DescriptionListenerTest {
ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......@@ -213,7 +213,7 @@ public class DescriptionListenerTest {
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......@@ -245,7 +245,7 @@ public class DescriptionListenerTest {
YangLeafList leafListInfo = leafListIterator.next();
// Check whether description value is set correctly.
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
}
}
\ No newline at end of file
}
......
......@@ -61,7 +61,7 @@ public class EnumListenerTest {
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("speed"));
assertThat(leafInfo.getName(), is("speed"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("enumeration"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.ENUMERATION));
assertThat(((YangEnumeration) leafInfo.getDataType().getDataTypeExtendedInfo()).getName(),
......
......@@ -64,7 +64,7 @@ public class GroupingListenerTest {
ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("address"));
assertThat(leafInfo.getName(), is("address"));
}
/**
......@@ -94,7 +94,7 @@ public class GroupingListenerTest {
ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("address"));
assertThat(leafInfo.getName(), is("address"));
}
/**
......@@ -124,7 +124,7 @@ public class GroupingListenerTest {
ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("address"));
assertThat(leafInfo.getName(), is("address"));
}
/**
......@@ -157,7 +157,7 @@ public class GroupingListenerTest {
ListIterator<YangLeaf> leafIterator = yangGrouping.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("address"));
assertThat(leafInfo.getName(), is("address"));
}
/**
......
......@@ -65,7 +65,7 @@ public class InputListenerTest {
ListIterator<YangLeaf> leafIterator = yangInput.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("image-name"));
assertThat(leafInfo.getName(), is("image-name"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
YangList yangList = (YangList) yangInput.getChild();
......@@ -76,7 +76,7 @@ public class InputListenerTest {
assertThat(yangList.getMinElements(), is(3));
leafIterator = yangList.getListOfLeaf().listIterator();
leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
YangContainer yangContainer = (YangContainer) yangList.getNextSibling();
......@@ -84,7 +84,7 @@ public class InputListenerTest {
leafIterator = yangContainer.getListOfLeaf().listIterator();
leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
}
......
......@@ -66,7 +66,7 @@ public class LeafListListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafListInfo.getUnits(), is("\"seconds\""));
......@@ -161,7 +161,7 @@ public class LeafListListenerTest {
ListIterator<YangLeafList> leafListIterator = container.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafListInfo.getUnits(), is("\"seconds\""));
......@@ -198,7 +198,7 @@ public class LeafListListenerTest {
ListIterator<YangLeafList> leafListIterator = yangList.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafListInfo.getUnits(), is("\"seconds\""));
......@@ -208,4 +208,4 @@ public class LeafListListenerTest {
assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
}
}
\ No newline at end of file
}
......
......@@ -67,7 +67,7 @@ public class LeafListenerTest {
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......@@ -161,7 +161,7 @@ public class LeafListenerTest {
ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......@@ -224,7 +224,7 @@ public class LeafListenerTest {
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......
......@@ -67,7 +67,7 @@ public class LengthRestrictionListenerTest {
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
......@@ -99,7 +99,7 @@ public class LengthRestrictionListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
......@@ -167,7 +167,7 @@ public class LengthRestrictionListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
......@@ -199,7 +199,7 @@ public class LengthRestrictionListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
......
......@@ -161,7 +161,7 @@ public class ListListenerTest {
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
assertThat(leafInfo.getUnits(), is("\"seconds\""));
......@@ -208,4 +208,4 @@ public class ListListenerTest {
thrown.expectMessage("YANG file error : list name 1valid is not valid.");
YangNode node = manager.getDataModel("src/test/resources/ListInvalidIdentifier.yang");
}
}
\ No newline at end of file
}
......
......@@ -64,7 +64,7 @@ public class MandatoryListenerTest {
YangLeaf leafInfo = leafIterator.next();
// Check whether the mandatory value is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.isMandatory(), is(true));
}
......@@ -90,7 +90,7 @@ public class MandatoryListenerTest {
YangLeaf leafInfo = leafIterator.next();
// Check whether the mandatory value is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.isMandatory(), is(false));
}
......@@ -116,7 +116,7 @@ public class MandatoryListenerTest {
YangLeaf leafInfo = leafIterator.next();
// Check whether the mandatory value is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.isMandatory(), is(false));
}
......@@ -154,4 +154,4 @@ public class MandatoryListenerTest {
+ " 'revision', 'rpc', 'typedef', 'uses', '}'}");
YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementMandatory.yang");
}
}
\ No newline at end of file
}
......
......@@ -64,7 +64,7 @@ public class MaxElementsListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getMaxElelements(), is(3));
}
......@@ -148,7 +148,7 @@ public class MaxElementsListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getMaxElelements(), is(2147483647));
}
......@@ -173,7 +173,7 @@ public class MaxElementsListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getMaxElelements(), is(2147483647));
}
}
\ No newline at end of file
}
......
......@@ -64,7 +64,7 @@ public class MinElementsListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getMinElements(), is(3));
}
......@@ -159,7 +159,7 @@ public class MinElementsListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getMinElements(), is(0));
}
}
\ No newline at end of file
}
......
......@@ -65,7 +65,7 @@ public class NotificationListenerTest {
ListIterator<YangLeaf> leafIterator = yangNotification.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("if-name"));
assertThat(leafInfo.getName(), is("if-name"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("leafref"));
}
}
......
......@@ -64,7 +64,7 @@ public class OutputListenerTest {
ListIterator<YangLeaf> leafIterator = yangOutput.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("image-name"));
assertThat(leafInfo.getName(), is("image-name"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
YangList yangList = (YangList) yangOutput.getChild();
......@@ -75,7 +75,7 @@ public class OutputListenerTest {
assertThat(yangList.getMinElements(), is(3));
leafIterator = yangList.getListOfLeaf().listIterator();
leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
YangContainer yangContainer = (YangContainer) yangList.getNextSibling();
......@@ -83,7 +83,7 @@ public class OutputListenerTest {
leafIterator = yangContainer.getListOfLeaf().listIterator();
leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
}
......
......@@ -58,7 +58,7 @@ public class PatternRestrictionListenerTest {
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
YangStringRestriction stringRestriction = (YangStringRestriction) leafInfo
......@@ -84,7 +84,7 @@ public class PatternRestrictionListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
......@@ -131,7 +131,7 @@ public class PatternRestrictionListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
......@@ -157,7 +157,7 @@ public class PatternRestrictionListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("string"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.STRING));
YangStringRestriction stringRestriction = (YangStringRestriction) leafListInfo
......
......@@ -61,7 +61,7 @@ public class PositionListenerTest {
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("mybits"));
assertThat(leafInfo.getName(), is("mybits"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("bits"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.BITS));
assertThat(((YangBits) leafInfo.getDataType().getDataTypeExtendedInfo()).getBitsName(),
......@@ -100,7 +100,7 @@ public class PositionListenerTest {
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("mybits"));
assertThat(leafInfo.getName(), is("mybits"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("bits"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.BITS));
assertThat(((YangBits) leafInfo.getDataType().getDataTypeExtendedInfo()).getBitsName(),
......@@ -139,7 +139,7 @@ public class PositionListenerTest {
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("mybits"));
assertThat(leafInfo.getName(), is("mybits"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("bits"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.BITS));
assertThat(((YangBits) leafInfo.getDataType().getDataTypeExtendedInfo()).getBitsName(),
......
......@@ -63,7 +63,7 @@ public class RangeRestrictionListenerTest {
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("int32"));
assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafInfo
......@@ -92,7 +92,7 @@ public class RangeRestrictionListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("int32"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafListInfo
......@@ -122,7 +122,7 @@ public class RangeRestrictionListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("int32"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafListInfo
......@@ -152,7 +152,7 @@ public class RangeRestrictionListenerTest {
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("int32"));
assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafListInfo
......@@ -175,4 +175,4 @@ public class RangeRestrictionListenerTest {
thrown.expectMessage("YANG file error : a is not valid.");
YangNode node = manager.getDataModel("src/test/resources/RangeWithInvalidIntegerPattern.yang");
}
}
\ No newline at end of file
}
......