Vinod Kumar S
Committed by Gerrit Code Review

[ONOS-3902, ONOS-3903, ONOS-3904] string type, integer type derrived type

Change-Id: I8279e93fcb7dfb82491cc09057c9d75165add68d
Showing 49 changed files with 1254 additions and 595 deletions
/*Copyright 2016.year 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.datamodel;
/**
* Abstraction of error message and application info processing.
*/
public interface YangAppErrorInfo {
/**
* Get the application's error message for data error.
*
* @return application's error message for data error.
*/
String getGetErrorMessage();
/**
* Set the application's error message for data error.
*
* @param errorMessage application's error message for data error.
*/
void setErrorMessage(String errorMessage);
/**
* Get the application's error tag for data error.
*
* @return application's error tag for data error.
*/
String getGetErrorAppTag();
/**
* Set the application's error tag for data error.
*
* @param errorMessage application's error tag for data error.
*/
void setErrorAppTag(String errorMessage);
}
......@@ -92,12 +92,12 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* List of leaves.
*/
private List<YangLeaf<?>> listOfLeaf;
private List<YangLeaf> listOfLeaf;
/**
* List of leaf-lists.
*/
private List<YangLeafList<?>> listOfLeafList;
private List<YangLeafList> listOfLeafList;
/**
* reference.
......@@ -110,6 +110,11 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
private YangStatusType status;
/**
* package of the generated java code.
*/
private String pkg;
/**
* Create a YANG augment node.
*/
public YangAugment() {
......@@ -160,7 +165,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
* @return the list of leaves.
*/
@Override
public List<YangLeaf<?>> getListOfLeaf() {
public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
......@@ -169,7 +174,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
*
* @param leafsList the list of leaf to set.
*/
private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
......@@ -179,9 +184,9 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
* @param leaf the leaf to be added.
*/
@Override
public void addLeaf(YangLeaf<?> leaf) {
public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
setListOfLeaf(new LinkedList<YangLeaf<?>>());
setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
......@@ -193,7 +198,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
* @return the list of leaf-list.
*/
@Override
public List<YangLeafList<?>> getListOfLeafList() {
public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
......@@ -202,7 +207,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
*
* @param listOfLeafList the list of leaf-list to set.
*/
private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
......@@ -212,9 +217,9 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
* @param leafList the leaf-list to be added.
*/
@Override
public void addLeafList(YangLeafList<?> leafList) {
public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
setListOfLeafList(new LinkedList<YangLeafList<?>>());
setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
......@@ -290,44 +295,51 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
/**
* Get the target nodes name where the augmentation is being done.
*
* @return target nodes name where the augmentation is being done.
*/
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
return targetNode;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
/**
* Set the target nodes name where the augmentation is being done.
*
* @param name target nodes name where the augmentation is being done.
*/
@Override
public void setName(String name) {
// TODO Auto-generated method stub
targetNode = name;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
/**
* Get the mapped java package.
*
* @return the java package
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
return pkg;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
/**
* Set the mapped java package.
*
* @param pakg the package to set
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
public void setPackage(String pakg) {
pkg = pakg;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
/**
* Prepare the information for java code generation corresponding to YANG
* grouping info.
*/
@Override
public void generateJavaCodeEntry() {
......@@ -335,8 +347,8 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
/**
* Create a java file using the YANG grouping info.
*/
@Override
public void generateJavaCodeExit() {
......
......@@ -114,6 +114,7 @@ public class YangBelongsTo implements Parsable {
*
* @return ParsedDataType returns BELONGS_TO_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.BELONGS_TO_DATA;
}
......@@ -123,6 +124,7 @@ public class YangBelongsTo implements Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
......@@ -132,6 +134,7 @@ public class YangBelongsTo implements Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
......
......@@ -101,6 +101,7 @@ public class YangBit implements YangCommonInfo, Parsable {
*
* @return the description.
*/
@Override
public String getDescription() {
return description;
}
......@@ -110,6 +111,7 @@ public class YangBit implements YangCommonInfo, Parsable {
*
* @param description set the description.
*/
@Override
public void setDescription(String description) {
this.description = description;
}
......@@ -119,6 +121,7 @@ public class YangBit implements YangCommonInfo, Parsable {
*
* @return the reference.
*/
@Override
public String getReference() {
return reference;
}
......@@ -128,6 +131,7 @@ public class YangBit implements YangCommonInfo, Parsable {
*
* @param reference the reference to set.
*/
@Override
public void setReference(String reference) {
this.reference = reference;
}
......@@ -137,6 +141,7 @@ public class YangBit implements YangCommonInfo, Parsable {
*
* @return the status.
*/
@Override
public YangStatusType getStatus() {
return status;
}
......@@ -146,6 +151,7 @@ public class YangBit implements YangCommonInfo, Parsable {
*
* @param status the status to set.
*/
@Override
public void setStatus(YangStatusType status) {
this.status = status;
}
......@@ -173,6 +179,7 @@ public class YangBit implements YangCommonInfo, Parsable {
*
* @return ParsedDataType returns BIT_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.BIT_DATA;
}
......@@ -182,6 +189,7 @@ public class YangBit implements YangCommonInfo, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
......@@ -191,6 +199,7 @@ public class YangBit implements YangCommonInfo, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
......
......@@ -77,6 +77,7 @@ public class YangBits implements Parsable {
*
* @return ParsedDataType returns BITS_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.BITS_DATA;
}
......@@ -86,6 +87,7 @@ public class YangBits implements Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
......@@ -95,6 +97,7 @@ public class YangBits implements Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
......
......@@ -89,7 +89,8 @@ import org.onosproject.yangutils.translator.CachedFileHandle;
/**
* Data model node to maintain information defined in YANG case.
*/
public class YangCase extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
public class YangCase extends YangNode
implements YangLeavesHolder, YangCommonInfo, Parsable {
/**
* Case name.
......@@ -106,12 +107,12 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn
/**
* List of leaves.
*/
private List<YangLeaf<?>> listOfLeaf;
private List<YangLeaf> listOfLeaf;
/**
* List of leaf lists.
*/
private List<YangLeafList<?>> listOfLeafList;
private List<YangLeafList> listOfLeafList;
/**
* Reference of the module.
......@@ -124,22 +125,31 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn
private YangStatusType status;
/**
* package of the generated java code.
*/
private String pkg;
/**
* Create a choice node.
*/
public YangCase() {
super(YangNodeType.CASE_NODE);
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
/**
* Get the case name.
*
* @return case name.
*/
@Override
public String getName() {
return name;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
/**
* Set the case name.
*
* @param name case name.
*/
@Override
public void setName(String name) {
......@@ -172,7 +182,7 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn
* @return the list of leaves.
*/
@Override
public List<YangLeaf<?>> getListOfLeaf() {
public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
......@@ -181,7 +191,7 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn
*
* @param leafsList the list of leaf to set.
*/
private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
......@@ -191,9 +201,9 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn
* @param leaf the leaf to be added.
*/
@Override
public void addLeaf(YangLeaf<?> leaf) {
public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
setListOfLeaf(new LinkedList<YangLeaf<?>>());
setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
......@@ -205,7 +215,7 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn
* @return the list of leaf-list.
*/
@Override
public List<YangLeafList<?>> getListOfLeafList() {
public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
......@@ -214,7 +224,7 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn
*
* @param listOfLeafList the list of leaf-list to set.
*/
private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
......@@ -224,9 +234,9 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn
* @param leafList the leaf-list to be added.
*/
@Override
public void addLeafList(YangLeafList<?> leafList) {
public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
setListOfLeafList(new LinkedList<YangLeafList<?>>());
setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
......@@ -302,26 +312,29 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
/**
* Get the mapped java package.
*
* @return the java package
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
return pkg;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
/**
* Set the mapped java package.
*
* @param pakg the package to set
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
public void setPackage(String pakg) {
pkg = pakg;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
/**
* Generate the code corresponding to YANG case info.
*/
@Override
public void generateJavaCodeEntry() {
......@@ -329,8 +342,9 @@ public class YangCase extends YangNode implements YangLeavesHolder, YangCommonIn
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
/**
* Free resource used for generating code and generate valid java files
* corresponding to YANG case info.
*/
@Override
public void generateJavaCodeExit() {
......
......@@ -109,12 +109,12 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* List of leaves contained.
*/
private List<YangLeaf<?>> listOfLeaf;
private List<YangLeaf> listOfLeaf;
/**
* List of leaf-lists contained.
*/
private List<YangLeafList<?>> listOfLeafList;
private List<YangLeafList> listOfLeafList;
/**
* If it is a presence container, then the textual documentation of presence
......@@ -130,7 +130,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Status of the node.
*/
private YangStatusType status;
private YangStatusType status = YangStatusType.CURRENT;
/**
* Package of the generated java code.
......@@ -149,16 +149,20 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
super(YangNodeType.CONTAINER_NODE);
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
/**
* Get the YANG name of container.
*
* @return the name of container as defined in YANG file.
*/
@Override
public String getName() {
return name;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
/**
* Set the YANG name of container.
*
* @param name the name of container as defined in YANG file.
*/
@Override
public void setName(String name) {
......@@ -209,7 +213,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
* @return the list of leaves.
*/
@Override
public List<YangLeaf<?>> getListOfLeaf() {
public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
......@@ -218,7 +222,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
*
* @param leafsList the list of leaf to set.
*/
private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
......@@ -228,9 +232,9 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
* @param leaf the leaf to be added.
*/
@Override
public void addLeaf(YangLeaf<?> leaf) {
public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
setListOfLeaf(new LinkedList<YangLeaf<?>>());
setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
......@@ -242,7 +246,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
* @return the list of leaf-list.
*/
@Override
public List<YangLeafList<?>> getListOfLeafList() {
public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
......@@ -251,7 +255,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
*
* @param listOfLeafList the list of leaf-list to set.
*/
private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
......@@ -261,9 +265,9 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
* @param leafList the leaf-list to be added.
*/
@Override
public void addLeafList(YangLeafList<?> leafList) {
public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
setListOfLeafList(new LinkedList<YangLeafList<?>>());
setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
......@@ -397,6 +401,11 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
pkg = pcg;
}
/**
* Generate the java code corresponding to YANG container.
*
* @throws IOException when fails to generate the source files.
*/
@Override
public void generateJavaCodeEntry() throws IOException {
YangNode parent = getParent();
......@@ -416,8 +425,6 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Adds current node attribute to parent file.
*
* @param pkg java file package path
*/
private void addAttributeInParent() {
if (getParent() != null) {
......@@ -439,9 +446,9 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
*/
private void addLeavesAttributes() {
List<YangLeaf<?>> leaves = getListOfLeaf();
List<YangLeaf> leaves = getListOfLeaf();
if (leaves != null) {
for (YangLeaf<?> leaf : leaves) {
for (YangLeaf leaf : leaves) {
getFileHandle().addAttributeInfo(leaf.getDataType(), leaf.getLeafName(), false);
}
}
......@@ -451,9 +458,9 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
* Adds leaf list's attributes in generated files.
*/
private void addLeafListAttributes() {
List<YangLeafList<?>> leavesList = getListOfLeafList();
List<YangLeafList> leavesList = getListOfLeafList();
if (leavesList != null) {
for (YangLeafList<?> leafList : leavesList) {
for (YangLeafList leafList : leavesList) {
getFileHandle().addAttributeInfo(leafList.getDataType(), leafList.getLeafName(), true);
}
}
......
......@@ -105,6 +105,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
*
* @return the description.
*/
@Override
public String getDescription() {
return description;
}
......@@ -114,6 +115,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
*
* @param description set the description.
*/
@Override
public void setDescription(String description) {
this.description = description;
}
......@@ -123,6 +125,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
*
* @return the reference.
*/
@Override
public String getReference() {
return reference;
}
......@@ -132,6 +135,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
*
* @param reference the reference to set.
*/
@Override
public void setReference(String reference) {
this.reference = reference;
}
......@@ -141,6 +145,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
*
* @return the status.
*/
@Override
public YangStatusType getStatus() {
return status;
}
......@@ -150,6 +155,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
*
* @param status the status to set.
*/
@Override
public void setStatus(YangStatusType status) {
this.status = status;
}
......@@ -177,6 +183,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
*
* @return ParsedDataType returns ENUM_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.ENUM_DATA;
}
......@@ -186,6 +193,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
......@@ -195,6 +203,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
......
......@@ -76,7 +76,8 @@ import org.onosproject.yangutils.translator.CachedFileHandle;
/**
* Data model node to maintain information defined in YANG grouping.
*/
public class YangGrouping extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
public class YangGrouping extends YangNode
implements YangLeavesHolder, YangCommonInfo, Parsable {
/**
* Name of the grouping.
......@@ -91,12 +92,12 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm
/**
* List of leaves.
*/
private List<YangLeaf<?>> listOfLeaf;
private List<YangLeaf> listOfLeaf;
/**
* List of leaf lists.
*/
private List<YangLeafList<?>> listOfLeafList;
private List<YangLeafList> listOfLeafList;
/**
* Reference of the module.
......@@ -109,22 +110,31 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm
private YangStatusType status;
/**
* package of the generated java code.
*/
private String pkg;
/**
* Creates the grouping node.
*/
public YangGrouping() {
super(YangNodeType.GROUPING_NODE);
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
/**
* Get YANG grouping name.
*
* @return YANG grouping name.
*/
@Override
public String getName() {
return name;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
/**
* Set YANG grouping name.
*
* @param name YANG grouping name.
*/
@Override
public void setName(String name) {
......@@ -157,7 +167,7 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm
* @return the list of leaves.
*/
@Override
public List<YangLeaf<?>> getListOfLeaf() {
public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
......@@ -166,7 +176,7 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm
*
* @param leafsList the list of leaf to set.
*/
private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
......@@ -176,9 +186,9 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm
* @param leaf the leaf to be added.
*/
@Override
public void addLeaf(YangLeaf<?> leaf) {
public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
setListOfLeaf(new LinkedList<YangLeaf<?>>());
setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
......@@ -190,7 +200,7 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm
* @return the list of leaf-list.
*/
@Override
public List<YangLeafList<?>> getListOfLeafList() {
public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
......@@ -199,7 +209,7 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm
*
* @param listOfLeafList the list of leaf-list to set.
*/
private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
......@@ -209,9 +219,9 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm
* @param leafList the leaf-list to be added.
*/
@Override
public void addLeafList(YangLeafList<?> leafList) {
public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
setListOfLeafList(new LinkedList<YangLeafList<?>>());
setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
......@@ -287,8 +297,8 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
/**
* Generate the code for YANG grouping.
*/
@Override
public void generateJavaCodeEntry() {
......@@ -296,8 +306,9 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
/**
* Free the resources used to generate java files corresponding to YANG
* grouping info and generate valid java files.
*/
@Override
public void generateJavaCodeExit() {
......@@ -305,21 +316,24 @@ public class YangGrouping extends YangNode implements YangLeavesHolder, YangComm
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
/**
* Get the mapped java package.
*
* @return the java package
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
return pkg;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
/**
* Set the mapped java package.
*
* @param pakg the package to set
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
public void setPackage(String pakg) {
pkg = pakg;
}
......
......@@ -76,6 +76,7 @@ public class YangImport implements Parsable {
/**
* Reference:RFC 6020.
*
* The import's "revision-date" statement is used to specify the exact
* version of the module to import. The "revision-date" statement MUST match
* the most recent "revision" statement in the imported module. organization
......@@ -150,6 +151,7 @@ public class YangImport implements Parsable {
*
* @return returns IMPORT_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.IMPORT_DATA;
}
......@@ -159,6 +161,7 @@ public class YangImport implements Parsable {
*
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......@@ -169,6 +172,7 @@ public class YangImport implements Parsable {
*
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......
......@@ -97,6 +97,7 @@ public class YangInclude implements Parsable {
*
* @return returns INCLUDE_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.INCLUDE_DATA;
}
......@@ -106,6 +107,7 @@ public class YangInclude implements Parsable {
*
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......@@ -116,6 +118,7 @@ public class YangInclude implements Parsable {
*
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......
......@@ -56,9 +56,8 @@ import org.onosproject.yangutils.parser.ParsableDataType;
/**
* Leaf data represented in YANG.
*
* @param <T> YANG data type
*/
public class YangLeaf<T> implements YangCommonInfo, Parsable {
public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Name of leaf.
......@@ -88,7 +87,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
/**
* Status of leaf in YANG definition.
*/
private YangStatusType status;
private YangStatusType status = YangStatusType.CURRENT;
/**
* Textual units info.
......@@ -98,7 +97,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
/**
* Data type of the leaf.
*/
private YangType<T> dataType;
private YangType<?> dataType;
/**
* Default constructor to create a YANG leaf.
......@@ -121,7 +120,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
* @param leafName the leaf name to set.
*/
public void setLeafName(String leafName) {
this.name = leafName;
name = leafName;
}
/**
......@@ -147,6 +146,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
*
* @return the description.
*/
@Override
public String getDescription() {
return description;
}
......@@ -156,6 +156,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
*
* @param description set the description.
*/
@Override
public void setDescription(String description) {
this.description = description;
}
......@@ -183,6 +184,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
*
* @return the reference.
*/
@Override
public String getReference() {
return reference;
}
......@@ -192,6 +194,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
*
* @param reference the reference to set.
*/
@Override
public void setReference(String reference) {
this.reference = reference;
}
......@@ -201,6 +204,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
*
* @return the status.
*/
@Override
public YangStatusType getStatus() {
return status;
}
......@@ -210,6 +214,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
*
* @param status the status to set.
*/
@Override
public void setStatus(YangStatusType status) {
this.status = status;
}
......@@ -237,7 +242,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
*
* @return the data type.
*/
public YangType<T> getDataType() {
public YangType<?> getDataType() {
return dataType;
}
......@@ -246,7 +251,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
*
* @param dataType the data type to set.
*/
public void setDataType(YangType<T> dataType) {
public void setDataType(YangType<?> dataType) {
this.dataType = dataType;
}
......@@ -255,6 +260,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
*
* @return returns LEAF_DATA.
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.LEAF_DATA;
}
......@@ -264,6 +270,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......@@ -274,6 +281,7 @@ public class YangLeaf<T> implements YangCommonInfo, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......
......@@ -51,10 +51,8 @@ import org.onosproject.yangutils.parser.ParsableDataType;
*/
/**
* Leaf-list data represented in YANG.
*
* @param <T> YANG data type
*/
public class YangLeafList<T> implements YangCommonInfo, Parsable {
public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Name of leaf-list.
......@@ -73,6 +71,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
/**
* Reference:RFC 6020.
*
* The "max-elements" statement, which is optional, takes as an argument a
* positive integer or the string "unbounded", which puts a constraint on
* valid list entries. A valid leaf-list or list always has at most
......@@ -80,10 +79,11 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* If no "max-elements" statement is present, it defaults to "unbounded".
*/
private int maxElelements;
private int maxElelements = Integer.MAX_VALUE;
/**
* Reference:RFC 6020.
*
* The "min-elements" statement, which is optional, takes as an argument a
* non-negative integer that puts a constraint on valid list entries. A
* valid leaf-list or list MUST have at least min-elements entries.
......@@ -99,7 +99,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* o Otherwise, it is enforced if the ancestor node exists.
*/
private int minElements;
private int minElements = 0;
/**
* The textual reference to this leaf-list.
......@@ -109,7 +109,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
/**
* Status of the leaf-list in the YANG definition.
*/
private YangStatusType status;
private YangStatusType status = YangStatusType.CURRENT;
/**
* Textual units.
......@@ -119,7 +119,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
/**
* Data type of leaf-list.
*/
private YangType<T> dataType;
private YangType<?> dataType;
/**
* Default Constructor to create a YANG leaf-list.
......@@ -142,7 +142,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
* @param leafListName the leaf-list name to set.
*/
public void setLeafName(String leafListName) {
this.name = leafListName;
name = leafListName;
}
/**
......@@ -168,6 +168,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* @return the description.
*/
@Override
public String getDescription() {
return description;
}
......@@ -177,6 +178,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* @param description set the description.
*/
@Override
public void setDescription(String description) {
this.description = description;
}
......@@ -222,6 +224,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* @return the reference.
*/
@Override
public String getReference() {
return reference;
}
......@@ -231,6 +234,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* @param reference the reference to set.
*/
@Override
public void setReference(String reference) {
this.reference = reference;
}
......@@ -240,6 +244,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* @return the status.
*/
@Override
public YangStatusType getStatus() {
return status;
}
......@@ -249,6 +254,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* @param status the status to set.
*/
@Override
public void setStatus(YangStatusType status) {
this.status = status;
}
......@@ -276,7 +282,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* @return the data type.
*/
public YangType<T> getDataType() {
public YangType<?> getDataType() {
return dataType;
}
......@@ -285,7 +291,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* @param dataType the data type to set.
*/
public void setDataType(YangType<T> dataType) {
public void setDataType(YangType<?> dataType) {
this.dataType = dataType;
}
......@@ -294,6 +300,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* @return returns LEAF_LIST_DATA.
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.LEAF_LIST_DATA;
}
......@@ -303,6 +310,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......@@ -313,6 +321,7 @@ public class YangLeafList<T> implements YangCommonInfo, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......
......@@ -27,26 +27,26 @@ public interface YangLeavesHolder {
*
* @return the list of leaves.
*/
public List<YangLeaf<?>> getListOfLeaf();
public List<YangLeaf> getListOfLeaf();
/**
* Add a leaf in data holder like container / list.
*
* @param leaf the leaf to be added.
*/
void addLeaf(YangLeaf<?> leaf);
void addLeaf(YangLeaf leaf);
/**
* Get the list of leaf-list from data holder like container / list.
*
* @return the list of leaf-list.
*/
List<YangLeafList<?>> getListOfLeafList();
List<YangLeafList> getListOfLeafList();
/**
* Add a leaf-list in data holder like container / list.
*
* @param leafList the leaf-list to be added.
*/
void addLeafList(YangLeafList<?> leafList);
void addLeafList(YangLeafList leafList);
}
......
......@@ -66,7 +66,8 @@ import org.onosproject.yangutils.translator.CachedFileHandle;
/**
* List data represented in YANG.
*/
public class YangList extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
public class YangList extends YangNode
implements YangLeavesHolder, YangCommonInfo, Parsable {
/**
* name of the YANG list.
......@@ -113,12 +114,12 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
/**
* List of leaves.
*/
private List<YangLeaf<?>> listOfLeaf;
private List<YangLeaf> listOfLeaf;
/**
* List of leaf-lists.
*/
private List<YangLeafList<?>> listOfLeafList;
private List<YangLeafList> listOfLeafList;
/**
* The "max-elements" statement, which is optional, takes as an argument a
......@@ -128,7 +129,7 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
*
* If no "max-elements" statement is present, it defaults to "unbounded".
*/
private int maxElelements;
private int maxElelements = Integer.MAX_VALUE;
/**
* The "min-elements" statement, which is optional, takes as an argument a
......@@ -146,7 +147,7 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
*
* o Otherwise, it is enforced if the ancestor node exists.
*/
private int minElements;
private int minElements = 0;
/**
* reference.
......@@ -157,7 +158,12 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
* Status of the node.
*/
private YangStatusType status;
private YangStatusType status = YangStatusType.CURRENT;
/**
* package of the generated java code.
*/
private String pkg;
/**
* Constructor.
......@@ -168,16 +174,20 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
super(type);
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
/**
* Get the YANG list name.
*
* @return YANG list name.
*/
@Override
public String getName() {
return name;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
/**
* Set the YANG list name.
*
* @param name YANG list name.
*/
@Override
public void setName(String name) {
......@@ -249,7 +259,6 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
if (getKeyList() == null) {
setKeyList(new LinkedList<String>());
}
getKeyList().add(key);
}
......@@ -259,7 +268,7 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
* @return the list of leaves.
*/
@Override
public List<YangLeaf<?>> getListOfLeaf() {
public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
......@@ -268,7 +277,7 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
*
* @param leafsList the list of leaf to set.
*/
private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
......@@ -278,9 +287,9 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
* @param leaf the leaf to be added.
*/
@Override
public void addLeaf(YangLeaf<?> leaf) {
public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
setListOfLeaf(new LinkedList<YangLeaf<?>>());
setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
......@@ -292,7 +301,7 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
* @return the list of leaf-list.
*/
@Override
public List<YangLeafList<?>> getListOfLeafList() {
public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
......@@ -301,7 +310,7 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
*
* @param listOfLeafList the list of leaf-list to set.
*/
private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
......@@ -311,9 +320,9 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
* @param leafList the leaf-list to be added.
*/
@Override
public void addLeafList(YangLeafList<?> leafList) {
public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
setListOfLeafList(new LinkedList<YangLeafList<?>>());
setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
......@@ -434,8 +443,9 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
/**
* Free the resources used to generate the java file corresponding to YANG
* list info.
*/
@Override
public void generateJavaCodeExit() {
......@@ -443,21 +453,24 @@ public class YangList extends YangNode implements YangLeavesHolder, YangCommonIn
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
/**
* Get the mapped java package.
*
* @return the java package
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
return pkg;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
/**
* Set the mapped java package.
*
* @param pakg the package to set
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
public void setPackage(String pakg) {
pkg = pakg;
}
......
......@@ -71,7 +71,8 @@ import org.onosproject.yangutils.utils.io.impl.FileSystemUtil;
/**
* Data model node to maintain information defined in YANG module.
*/
public class YangModule extends YangNode implements YangLeavesHolder, YangDesc, YangReference, Parsable, CodeGenerator {
public class YangModule extends YangNode
implements YangLeavesHolder, YangDesc, YangReference, Parsable, CodeGenerator {
/**
* Name of the module.
......@@ -112,12 +113,12 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc,
/**
* List of leaves at root level in the module.
*/
private List<YangLeaf<?>> listOfLeaf;
private List<YangLeaf> listOfLeaf;
/**
* List of leaf-lists at root level in the module.
*/
private List<YangLeafList<?>> listOfLeafList;
private List<YangLeafList> listOfLeafList;
/**
* Name space of the module.
......@@ -298,7 +299,7 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc,
* @return the list of leaves.
*/
@Override
public List<YangLeaf<?>> getListOfLeaf() {
public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
......@@ -307,7 +308,7 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc,
*
* @param leafsList the list of leaf to set.
*/
private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
......@@ -317,9 +318,9 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc,
* @param leaf the leaf to be added.
*/
@Override
public void addLeaf(YangLeaf<?> leaf) {
public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
setListOfLeaf(new LinkedList<YangLeaf<?>>());
setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
......@@ -331,7 +332,7 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc,
* @return the list of leaf-list.
*/
@Override
public List<YangLeafList<?>> getListOfLeafList() {
public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
......@@ -340,7 +341,7 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc,
*
* @param listOfLeafList the list of leaf-list to set.
*/
private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
......@@ -350,9 +351,9 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc,
* @param leafList the leaf-list to be added.
*/
@Override
public void addLeafList(YangLeafList<?> leafList) {
public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
setListOfLeafList(new LinkedList<YangLeafList<?>>());
setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
......@@ -525,7 +526,10 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc,
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
/*
* Module is root in the data model tree, hence there is no entry
* validation
*/
}
/**
......@@ -535,7 +539,10 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc,
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
/*
* TODO: perform symbol linking for the imported or included YANG info.
* TODO: perform symbol resolution for referred YANG entities.
*/
}
/**
......@@ -572,9 +579,9 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc,
*/
private void addLeavesAttributes() {
List<YangLeaf<?>> leaves = getListOfLeaf();
List<YangLeaf> leaves = getListOfLeaf();
if (leaves != null) {
for (YangLeaf<?> leaf : leaves) {
for (YangLeaf leaf : leaves) {
getFileHandle().addAttributeInfo(leaf.getDataType(), leaf.getLeafName(), false);
}
}
......@@ -584,9 +591,9 @@ public class YangModule extends YangNode implements YangLeavesHolder, YangDesc,
* Adds leaf list's attributes in generated files.
*/
private void addLeafListAttributes() {
List<YangLeafList<?>> leavesList = getListOfLeafList();
List<YangLeafList> leavesList = getListOfLeafList();
if (leavesList != null) {
for (YangLeafList<?> leafList : leavesList) {
for (YangLeafList leafList : leavesList) {
getFileHandle().addAttributeInfo(leafList.getDataType(), leafList.getLeafName(), true);
}
}
......
......@@ -92,6 +92,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
*
* @return the description.
*/
@Override
public String getDescription() {
return description;
}
......@@ -101,6 +102,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
*
* @param description set the description.
*/
@Override
public void setDescription(String description) {
this.description = description;
}
......@@ -110,6 +112,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
*
* @return the reference.
*/
@Override
public String getReference() {
return reference;
}
......@@ -119,6 +122,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
*
* @param reference the reference to set.
*/
@Override
public void setReference(String reference) {
this.reference = reference;
}
......@@ -128,6 +132,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
*
* @return returns MUST_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.MUST_DATA;
}
......@@ -137,6 +142,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
......@@ -146,6 +152,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
......
......@@ -65,6 +65,7 @@ public class YangNameSpace implements Parsable {
*
* @return returns NAMESPACE_DATA.
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.NAMESPACE_DATA;
}
......@@ -74,6 +75,7 @@ public class YangNameSpace implements Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......@@ -84,6 +86,7 @@ public class YangNameSpace implements Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......
/*Copyright 2016.year 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.datamodel;
import java.util.List;
/*-
* Reference RFC 6020.
*
* The pattern Statement
*
* The "pattern" statement, which is an optional sub-statement to the
* "type" statement, takes as an argument a regular expression string.
* It is used to restrict the built-in type "string", or types derived
* from "string", to values that match the pattern.
*
* If the type has multiple "pattern" statements, the expressions are
* ANDed together, i.e., all such expressions have to match.
*
* If a pattern restriction is applied to an already pattern-restricted
* type, values must match all patterns in the base type, in addition to
* the new patterns.
* The pattern's sub-statements
*
* +---------------+---------+-------------+
* | substatement | section | cardinality |
* +---------------+---------+-------------+
* | description | 7.19.3 | 0..1 |
* | error-app-tag | 7.5.4.2 | 0..1 |
* | error-message | 7.5.4.1 | 0..1 |
* | reference | 7.19.4 | 0..1 |
* +---------------+---------+-------------+
*/
/**
* Pattern restriction information. The regular expression restriction on string
* data type.
*/
public class YangPatternRestriction {
/**
* Pattern restriction defined for the current type.
*/
private List<String> pattern;
/**
* Effective pattern restriction that needs inherited from base type.
*/
private List<String> basePattern;
/**
* Default constructor.
*/
public YangPatternRestriction() {
}
/**
* Get the pattern restriction defined for the current type.
*
* @return pattern restriction defined for the current type.
*/
public List<String> getPattern() {
return pattern;
}
/**
* Set the pattern restriction defined for the current type.
*
* @param pattern pattern restriction defined for the current type..
*/
public void setPattern(List<String> pattern) {
this.pattern = pattern;
}
/**
* Get the pattern restriction defined in base type.
*
* @return pattern restriction defined in base type.
*/
public List<String> getBasePattern() {
return basePattern;
}
/**
* Set the pattern restriction defined in base type.
*
* @param basePattern pattern restriction defined in base type.
*/
public void setBasePattern(List<String> basePattern) {
this.basePattern = basePattern;
}
}
/*Copyright 2016.year 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.datamodel;
/**
* Single interval information of a range.
*
* @param <T> range type based on the data type.
*/
public class YangRangeInterval<T extends Comparable<T>> {
/**
* Starting value of the range interval.
*/
private T startValue;
/**
* Last value of the range interval.
*/
private T endValue;
/**
* Default constructor.
*/
public YangRangeInterval() {
}
/**
* Get the starting value of the range interval.
*
* @return the starting value of the range interval.
*/
public T getStartValue() {
return startValue;
}
/**
* Set the starting value of the range interval.
*
* @param startValue the starting value of the range interval.
*/
public void setStartValue(T startValue) {
this.startValue = startValue;
}
/**
* Get the last value of the range interval.
*
* @return last value of the range interval.
*/
public T getEndValue() {
return endValue;
}
/**
* Set the last value of the range interval.
*
* @param endValue last value of the range interval.
*/
public void setEndValue(T endValue) {
this.endValue = endValue;
}
}
/*Copyright 2016.year 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.datamodel;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import static com.google.common.base.Preconditions.checkNotNull;
/*-
* Reference RFC 6020.
*
* The range Statement
*
* The "range" statement, which is an optional sub-statement to the
* "type" statement, takes as an argument a range expression string. It
* is used to restrict integer and decimal built-in types, or types
* derived from those.
*
* A range consists of an explicit value, or a lower-inclusive bound,
* two consecutive dots "..", and an upper-inclusive bound. Multiple
* values or ranges can be given, separated by "|". If multiple values
* or ranges are given, they all MUST be disjoint and MUST be in
* ascending order. If a range restriction is applied to an already
* range-restricted type, the new restriction MUST be equal or more
* limiting, that is raising the lower bounds, reducing the upper
* bounds, removing explicit values or ranges, or splitting ranges into
* multiple ranges with intermediate gaps. Each explicit value and
* range boundary value given in the range expression MUST match the
* type being restricted, or be one of the special values "min" or
* "max". "min" and "max" mean the minimum and maximum value accepted
* for the type being restricted, respectively.
*/
/**
* Ascending range restriction information.
*
* @param <T> range type (data type)
*/
public class YangRangeRestriction<T extends Comparable<T>> implements YangDesc, YangReference, YangAppErrorInfo {
/**
* Ascending list of range interval restriction. If the restriction is a
* single value, the start and end length of the range is same.
*/
private List<YangRangeInterval<T>> ascendingRangeIntervals;
/**
* Textual reference.
*/
private String reference;
/**
* Application's error message, to be used for data error.
*/
private String errorMessage;
/**
* Application's error tag, to be filled in data validation error response.
*/
private String errorAppTag;
/**
* Textual description.
*/
private String description;
/**
* Default constructor.
*/
public YangRangeRestriction() {
}
/**
* Get the list of range interval restriction in ascending order.
*
* @return list of range interval restriction in ascending order.
*/
public List<YangRangeInterval<T>> getAscendingRangeIntervals() {
return ascendingRangeIntervals;
}
/**
* Set the list of range interval restriction in ascending order.
*
* @param rangeList list of range interval restriction in ascending order.
*/
private void setAscendingRangeIntervals(List<YangRangeInterval<T>> rangeList) {
ascendingRangeIntervals = rangeList;
}
/**
* Get the minimum valid value as per the restriction.
*
* @throws DataModelException data model exception for minimum restriction.
*
* @return minimum restricted value.
*/
public T getMinRestrictedvalue() throws DataModelException {
if (getAscendingRangeIntervals() == null) {
throw new DataModelException("No range restriction info");
}
if (getAscendingRangeIntervals().size() == 0) {
throw new DataModelException("No range interval info");
}
return getAscendingRangeIntervals().get(0).getStartValue();
}
/**
* Get the maximum valid value as per the restriction.
*
* @throws DataModelException data model exception for maximum restriction.
*
* @return minimum maximum value.
*/
public T getMaxRestrictedvalue() throws DataModelException {
if (getAscendingRangeIntervals() == null) {
throw new DataModelException("No range restriction info");
}
if (getAscendingRangeIntervals().size() == 0) {
throw new DataModelException("No range interval info");
}
return getAscendingRangeIntervals()
.get(getAscendingRangeIntervals().size() - 1).getEndValue();
}
/**
* Add new interval to extend its range in the last. i.e. newly added
* interval needs to be bigger than the biggest interval in the list.
*
* @param newInterval restricted length interval.
* @throws DataModelException data model exception for range restriction.
*/
public void addLenghtRestrictionInterval(YangRangeInterval<T> newInterval) throws DataModelException {
checkNotNull(newInterval);
checkNotNull(newInterval.getStartValue());
if (getAscendingRangeIntervals() == null) {
/*
* First interval that is being added, and it must be the smallest
* interval.
*/
setAscendingRangeIntervals(new LinkedList<YangRangeInterval<T>>());
getAscendingRangeIntervals().add(newInterval);
return;
}
T curMaxvalue = getMaxRestrictedvalue();
if (newInterval.getStartValue().compareTo(curMaxvalue) != 1) {
throw new DataModelException(
"New added range interval is lesser than the old interval(s)");
}
getAscendingRangeIntervals()
.add(getAscendingRangeIntervals().size(), newInterval);
}
/**
* Get the textual reference of the length restriction.
*
* @return textual reference of the length restriction.
*/
@Override
public String getReference() {
return reference;
}
/**
* Set the textual reference of the length restriction.
*
* @param ref textual reference of the length restriction.
*/
@Override
public void setReference(String ref) {
reference = ref;
}
/**
* Get the description of the length restriction.
*
* @return description of the length restriction.
*/
@Override
public String getDescription() {
return description;
}
/**
* Set the description of the length restriction.
*
* @param desc description of the length restriction.
*/
@Override
public void setDescription(String desc) {
description = desc;
}
/**
* Get application's error message, to be used for data error.
*
* @return Application's error message, to be used for data error.
*/
@Override
public String getGetErrorMessage() {
return errorMessage;
}
/**
* Set Application's error message, to be used for data error.
*
* @param errMsg Application's error message, to be used for data error.
*/
@Override
public void setErrorMessage(String errMsg) {
errorMessage = errMsg;
}
/**
* Get application's error tag, to be used for data error.
*
* @return application's error tag, to be used for data error.
*/
@Override
public String getGetErrorAppTag() {
return errorAppTag;
}
/**
* Set application's error tag, to be used for data error.
*
* @param errTag application's error tag, to be used for data error.
*/
@Override
public void setErrorAppTag(String errTag) {
errorAppTag = errTag;
}
}
......@@ -88,6 +88,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
*
* @return the description.
*/
@Override
public String getDescription() {
return description;
}
......@@ -97,6 +98,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
*
* @param description set the description.
*/
@Override
public void setDescription(String description) {
this.description = description;
}
......@@ -106,6 +108,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
*
* @return the reference.
*/
@Override
public String getReference() {
return reference;
}
......@@ -115,6 +118,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
*
* @param reference the reference to set.
*/
@Override
public void setReference(String reference) {
this.reference = reference;
}
......@@ -124,6 +128,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
*
* @return returns REVISION_DATA.
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.REVISION_DATA;
}
......@@ -133,6 +138,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......@@ -143,6 +149,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......
/*Copyright 2016.year 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.datamodel;
import java.math.BigInteger;
/*-
* Reference RFC 6020.
*
* A string can be restricted with the "length" and "pattern" statements.
*
*/
/**
* The restriction for string data type.
*/
public class YangStringRestriction {
/*-
* Reference RFC 6020.
* The length Statement
*
* The "length" statement, which is an optional sub-statement to the
* "type" statement, takes as an argument a length expression string.
* It is used to restrict the built-in type "string", or types derived
* from "string".
* A "length" statement restricts the number of unicode characters in
* the string.
* A length range consists of an explicit value, or a lower bound, two
* consecutive dots "..", and an upper bound. Multiple values or ranges
* can be given, separated by "|". Length-restricting values MUST NOT
* be negative. If multiple values or ranges are given, they all MUST
* be disjoint and MUST be in ascending order. If a length restriction
* is applied to an already length-restricted type, the new restriction
* MUST be equal or more limiting, that is, raising the lower bounds,
* reducing the upper bounds, removing explicit length values or ranges,
* or splitting ranges into multiple ranges with intermediate gaps. A
* length value is a non-negative integer, or one of the special values
* "min" or "max". "min" and "max" mean the minimum and maximum length
* accepted for the type being restricted, respectively. An
* implementation is not required to support a length value larger than
* 18446744073709551615.
* The length's sub-statements
*
* +---------------+---------+-------------+-----------------+
* | substatement | section | cardinality | mapped data type|
* +---------------+---------+-------------+-----------------+
* | description | 7.19.3 | 0..1 | string |
* | error-app-tag | 7.5.4.2 | 0..1 | string |
* | error-message | 7.5.4.1 | 0..1 | string |
* | reference | 7.19.4 | 0..1 | string |
* +---------------+---------+-------------+-----------------+
*/
/**
* Length restriction information.
*/
private YangRangeRestriction<BigInteger> lengthRestriction;
/**
* Effective pattern restriction for the type.
*/
private YangPatternRestriction patternRestriction;
/**
* Default constructor.
*/
public YangStringRestriction() {
}
/**
* Get the length restriction on the string data.
*
* @return length restriction on the string data.
*/
public YangRangeRestriction<BigInteger> getLengthRestriction() {
return lengthRestriction;
}
/**
* Set the length restriction on the string data.
*
* @param lengthRestriction length restriction on the string data.
*/
public void setLengthRestriction(YangRangeRestriction<BigInteger> lengthRestriction) {
this.lengthRestriction = lengthRestriction;
}
/**
* Get the pattern restriction for the type.
*
* @return pattern restriction for the type.
*/
public YangPatternRestriction getPatternRestriction() {
return patternRestriction;
}
/**
* Set the pattern restriction for the type.
*
* @param patternRestriction pattern restriction for the type.
*/
public void setPatternRestriction(YangPatternRestriction patternRestriction) {
this.patternRestriction = patternRestriction;
}
}
......@@ -73,7 +73,8 @@ import org.onosproject.yangutils.translator.CachedFileHandle;
/**
* Data model node to maintain information defined in YANG sub-module.
*/
public class YangSubModule extends YangNode implements YangLeavesHolder, YangDesc, YangReference, Parsable {
public class YangSubModule extends YangNode
implements YangLeavesHolder, YangDesc, YangReference, Parsable {
/**
* Name of sub module.
......@@ -114,12 +115,12 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes
/**
* List of leaves at root level in the sub-module.
*/
private List<YangLeaf<?>> listOfLeaf;
private List<YangLeaf> listOfLeaf;
/**
* List of leaf-lists at root level in the sub-module.
*/
private List<YangLeafList<?>> listOfLeafList;
private List<YangLeafList> listOfLeafList;
/**
* organization owner of the sub-module.
......@@ -142,22 +143,31 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes
private byte version;
/**
* package of the generated java code.
*/
private String pkg;
/**
* Create a sub module node.
*/
public YangSubModule() {
super(YangNodeType.SUB_MODULE_NODE);
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
/**
* Get the YANG name of the sub module.
*
* @return YANG name of the sub module
*/
@Override
public String getName() {
return name;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
/**
* Set YANG name of the sub module.
*
* @param subModuleName YANG name of the sub module
*/
@Override
public void setName(String subModuleName) {
......@@ -293,7 +303,7 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes
* @return the list of leaves.
*/
@Override
public List<YangLeaf<?>> getListOfLeaf() {
public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
......@@ -302,7 +312,7 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes
*
* @param leafsList the list of leaf to set.
*/
private void setListOfLeaf(List<YangLeaf<?>> leafsList) {
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
......@@ -312,9 +322,9 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes
* @param leaf the leaf to be added.
*/
@Override
public void addLeaf(YangLeaf<?> leaf) {
public void addLeaf(YangLeaf leaf) {
if (getListOfLeaf() == null) {
setListOfLeaf(new LinkedList<YangLeaf<?>>());
setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
......@@ -326,7 +336,7 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes
* @return the list of leaf-list.
*/
@Override
public List<YangLeafList<?>> getListOfLeafList() {
public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
......@@ -335,7 +345,7 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes
*
* @param listOfLeafList the list of leaf-list to set.
*/
private void setListOfLeafList(List<YangLeafList<?>> listOfLeafList) {
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
......@@ -345,9 +355,9 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes
* @param leafList the leaf-list to be added.
*/
@Override
public void addLeafList(YangLeafList<?> leafList) {
public void addLeafList(YangLeafList leafList) {
if (getListOfLeafList() == null) {
setListOfLeafList(new LinkedList<YangLeafList<?>>());
setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
......@@ -457,17 +467,16 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
/**
* Generates java code for sub-module.
*/
@Override
public void generateJavaCodeEntry() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
/**
* Free resources used to generate code.
*/
@Override
public void generateJavaCodeExit() {
......@@ -475,22 +484,24 @@ public class YangSubModule extends YangNode implements YangLeavesHolder, YangDes
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
/**
* Get the mapped java package.
*
* @return the java package
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
return pkg;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
/**
* Set the mapped java package.
*
* @param pakg the package to set
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
public void setPackage(String pakg) {
pkg = pakg;
}
@Override
......
......@@ -61,7 +61,12 @@ public class YangType<T> implements Parsable {
*/
private YangDataTypes dataType;
private T dataTypeInfo;
/**
* Additional information about data type, example restriction info, named
* values, etc. The extra information is based on the data type. Based on
* the data type, the extended info can vary.
*/
private T dataTypeExtendedInfo;
/**
* Default constructor.
......@@ -110,8 +115,8 @@ public class YangType<T> implements Parsable {
*
* @return the data type meta data.
*/
public T getDataTypeInfo() {
return dataTypeInfo;
public T getDataTypeExtendedInfo() {
return dataTypeExtendedInfo;
}
/**
......@@ -119,8 +124,8 @@ public class YangType<T> implements Parsable {
*
* @param dataTypeInfo the meta data to set
*/
public void setDataTypeInfo(T dataTypeInfo) {
this.dataTypeInfo = dataTypeInfo;
public void setDataTypeExtendedInfo(T dataTypeInfo) {
this.dataTypeExtendedInfo = dataTypeInfo;
}
/**
......@@ -128,6 +133,7 @@ public class YangType<T> implements Parsable {
*
* @return returns TYPE_DATA.
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.TYPE_DATA;
}
......@@ -137,6 +143,7 @@ public class YangType<T> implements Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......@@ -147,6 +154,7 @@ public class YangType<T> implements Parsable {
*
* @throws DataModelException a violation of data model rules.
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
......
......@@ -81,10 +81,14 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
private YangStatusType status;
/**
* Derived data type.
* Derived data type. The type will be set when the parser detects the type
* parsing. Hence it is of raw type and it not know at the time of creation
* of the object. i.e. in entry parse, it will not be know, in the exit
* parse we may know the type implicitly based on the restriction. We must
* know and validate the base built in type, by the linking phase. It is a
* RAW type and it usage needs to be validate in linking phase.
*/
@SuppressWarnings("rawtypes")
private YangType derivedType;
private YangType<?> derivedType;
/**
* Units of the data type.
......@@ -92,6 +96,16 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
private String units;
/**
* YANG base built in data type.
*/
private YangDataTypes baseBuiltInType;
/**
* package of the generated java code.
*/
private String pkg;
/**
* Create a typedef node.
*/
public YangTypeDef() {
......@@ -199,8 +213,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
*
* @return the referenced type.
*/
@SuppressWarnings("rawtypes")
public YangType getDerivedType() {
public YangType<?> getDerivedType() {
return derivedType;
}
......@@ -209,8 +222,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
*
* @param derivedType the referenced type.
*/
@SuppressWarnings("rawtypes")
public void setDerivedType(YangType derivedType) {
public void setDerivedType(YangType<?> derivedType) {
this.derivedType = derivedType;
}
......@@ -233,6 +245,24 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
}
/**
* Get the base built in YANG data type.
*
* @return base built in YANG data type.
*/
public YangDataTypes getBaseBuiltInType() {
return baseBuiltInType;
}
/**
* Set the base built in YANG data type.
*
* @param baseBuiltInType base built in YANG data type.
*/
public void setBaseBuiltInType(YangDataTypes baseBuiltInType) {
this.baseBuiltInType = baseBuiltInType;
}
/**
* Returns the type of the data.
*
* @return returns TYPEDEF_DATA
......@@ -262,17 +292,20 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
/**
* Get the YANG name of the typedef.
*
* @return YANG name of the typedef.
*/
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
return derivedName;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
/**
* Set YANG name of the typedef.
*
* @param name YANG name of the typedef.
*/
@Override
public void setName(String name) {
......@@ -280,8 +313,8 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
/**
* Generate java code snippet corresponding to YANG typedef.
*/
@Override
public void generateJavaCodeEntry() {
......@@ -289,8 +322,8 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
/**
* Free resource used for code generation of YANG typedef.
*/
@Override
public void generateJavaCodeExit() {
......@@ -298,30 +331,43 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
/**
* Get the mapped java package.
*
* @return the java package
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
return pkg;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
/**
* Set the mapped java package.
*
* @param pakg mapped java package.
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
public void setPackage(String pakg) {
pkg = pakg;
}
/**
* Get the file handle of the cached file used during code generation.
*
* @return cached file handle.
*/
@Override
public CachedFileHandle getFileHandle() {
// TODO Auto-generated method stub
return null;
}
/**
* Set the file handle to be used used for code generation.
*
* @param fileHandle cached file handle.
*/
@Override
public void setFileHandle(CachedFileHandle fileHandle) {
// TODO Auto-generated method stub
......
......@@ -909,8 +909,8 @@ public interface GeneratedYangListener extends ParseTreeListener {
*
* @param currentContext current context in the parsed tree.
*/
void enterInstanceIdentifierSpecification(GeneratedYangParser.InstanceIdentifierSpecificationContext
currentContext);
void enterInstanceIdentifierSpecification(
GeneratedYangParser.InstanceIdentifierSpecificationContext currentContext);
/**
* Exit a parse tree produced by GeneratedYangParser for grammar rule
......
......@@ -16,6 +16,8 @@
package org.onosproject.yangutils.parser.impl;
import java.util.Stack;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ErrorNode;
import org.antlr.v4.runtime.tree.TerminalNode;
......@@ -23,20 +25,19 @@ import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangListener;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.impl.listeners.DefaultListener;
import org.onosproject.yangutils.parser.impl.listeners.KeyListener;
import org.onosproject.yangutils.parser.impl.listeners.LeafListListener;
import org.onosproject.yangutils.parser.impl.listeners.LeafListener;
import org.onosproject.yangutils.parser.impl.listeners.ListListener;
import org.onosproject.yangutils.parser.impl.listeners.ContainerListener;
import org.onosproject.yangutils.parser.impl.listeners.ConfigListener;
import org.onosproject.yangutils.parser.impl.listeners.ContactListener;
import org.onosproject.yangutils.parser.impl.listeners.BaseFileListener;
import org.onosproject.yangutils.parser.impl.listeners.BelongsToListener;
import org.onosproject.yangutils.parser.impl.listeners.ConfigListener;
import org.onosproject.yangutils.parser.impl.listeners.ContactListener;
import org.onosproject.yangutils.parser.impl.listeners.ContainerListener;
import org.onosproject.yangutils.parser.impl.listeners.DefaultListener;
import org.onosproject.yangutils.parser.impl.listeners.DescriptionListener;
import org.onosproject.yangutils.parser.impl.listeners.ImportListener;
import org.onosproject.yangutils.parser.impl.listeners.IncludeListener;
import org.onosproject.yangutils.parser.impl.listeners.KeyListener;
import org.onosproject.yangutils.parser.impl.listeners.LeafListListener;
import org.onosproject.yangutils.parser.impl.listeners.LeafListener;
import org.onosproject.yangutils.parser.impl.listeners.ListListener;
import org.onosproject.yangutils.parser.impl.listeners.MandatoryListener;
import org.onosproject.yangutils.parser.impl.listeners.MaxElementsListener;
import org.onosproject.yangutils.parser.impl.listeners.MinElementsListener;
......@@ -54,9 +55,6 @@ import org.onosproject.yangutils.parser.impl.listeners.TypeDefListener;
import org.onosproject.yangutils.parser.impl.listeners.TypeListener;
import org.onosproject.yangutils.parser.impl.listeners.UnitsListener;
import org.onosproject.yangutils.parser.impl.listeners.VersionListener;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerError;
import java.util.Stack;
/**
* ANTLR generates a parse-tree listener interface that responds to events
......@@ -72,9 +70,6 @@ public class TreeWalkListener implements GeneratedYangListener {
// Parse tree root node
private YangNode rootNode;
// Maintains the state of Exception.
private ListenerError errorInformation = new ListenerError();
/**
* Returns stack of parsable data.
*
......@@ -85,15 +80,6 @@ public class TreeWalkListener implements GeneratedYangListener {
}
/**
* Returns error information.
*
* @return error information object having exception flag and message
*/
public ListenerError getErrorInformation() {
return errorInformation;
}
/**
* Returns root node.
*
* @return rootNode of data model tree.
......@@ -120,15 +106,6 @@ public class TreeWalkListener implements GeneratedYangListener {
this.rootNode = rootNode;
}
/**
* Set listener error information.
*
* @param errorInformation error occurred during tree walk.
*/
public void setErrorInformation(ListenerError errorInformation) {
this.errorInformation = errorInformation;
}
@Override
public void enterYangfile(GeneratedYangParser.YangfileContext ctx) {
BaseFileListener.processYangFileEntry(this, ctx);
......
......@@ -59,15 +59,14 @@ public final class ConfigListener {
}
/**
* It is called when parser receives an input matching the grammar
* rule (config), performs validation and updates the data model
* tree.
* It is called when parser receives an input matching the grammar rule
* (config), performs validation and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
*/
public static void processConfigEntry(TreeWalkListener listener,
GeneratedYangParser.ConfigStatementContext ctx) {
GeneratedYangParser.ConfigStatementContext ctx) {
boolean isConfig = false;
// Check for stack to be non empty.
......
......@@ -56,26 +56,27 @@ import org.onosproject.yangutils.datamodel.YangTypeDef;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import static org.onosproject.yangutils.parser.ParsableDataType.TYPEDEF_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.UNITS_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.DEFAULT_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.REFERENCE_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.STATUS_DATA;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import static org.onosproject.yangutils.parser.ParsableDataType.DEFAULT_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.REFERENCE_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.STATUS_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.TYPEDEF_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.UNITS_DATA;
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.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
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;
/**
......@@ -115,8 +116,8 @@ public final class TypeDefListener {
Parsable curData = listener.getParsedDataStack().peek();
if (curData instanceof YangModule | curData instanceof YangSubModule | curData instanceof YangContainer
| curData instanceof YangList) {
if ((curData instanceof YangModule) | (curData instanceof YangSubModule) | (curData instanceof YangContainer)
| (curData instanceof YangList)) {
/*
* TODO YangGrouping, YangRpc, YangInput, YangOutput, Notification.
*/
......@@ -150,7 +151,6 @@ public final class TypeDefListener {
if (listener.getParsedDataStack().peek() instanceof YangTypeDef) {
listener.getParsedDataStack().pop();
} else {
listener.getErrorInformation().setErrorFlag(true);
throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, TYPEDEF_DATA,
ctx.IDENTIFIER().getText(), EXIT));
}
......
/*
* Copyright 2016 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.parser.impl.parserutils;
/**
* Error information while doing a listener's based walk is maintained in it.
*/
public class ListenerError {
// Maintains the state of exception.
private boolean errorFlag = false;
// Maintains the reason of exception.
private String errorMsg;
// Maintains the line number of exception.
private int lineNumber;
// Maintains the character position in lin of exception.
private int charPositionInLine;
/**
* Returns error flag.
*
* @return error flag.
*/
public boolean isErrorFlag() {
return errorFlag;
}
/**
* Returns reason for error.
*
* @return error message
*/
public String getErrorMsg() {
return errorMsg;
}
/**
* Returns error line number.
*
* @return error line number.
*/
public int getLineNumber() {
return lineNumber;
}
/**
* Returns error position in line.
*
* @return error character position in line.
*/
public int getCharPositionInLine() {
return charPositionInLine;
}
/**
* Set error flag.
*
* @param errorFlag error existence flag.
*/
public void setErrorFlag(boolean errorFlag) {
this.errorFlag = errorFlag;
}
/**
* Set error message.
*
* @param errorMsg reason for error.
*/
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
/**
* Set error line number.
*
* @param lineNumber line number of error.
*/
public void setLineNumber(int lineNumber) {
this.lineNumber = lineNumber;
}
/**
* Set error character position in line.
*
* @param charPositionInLine error character position in line.
*/
public void setCharPositionInLine(int charPositionInLine) {
this.charPositionInLine = charPositionInLine;
}
}
\ No newline at end of file
......@@ -46,7 +46,7 @@ import org.sonatype.plexus.build.incremental.BuildContext;
* in generate-sources requiresDependencyResolution at compile time
*/
@Mojo(name = "yang2java", defaultPhase = LifecyclePhase.GENERATE_SOURCES,
requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true)
requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true)
public class YangUtilManager extends AbstractMojo {
/**
......
......@@ -16,6 +16,9 @@
package org.onosproject.yangutils.translator.tojava.utils;
import java.util.List;
import java.util.SortedSet;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.translator.GeneratedFileType;
import org.onosproject.yangutils.translator.tojava.GeneratedMethodTypes;
......@@ -47,6 +50,17 @@ public final class JavaCodeSnippetGen {
}
/**
* reorder the import list based on the ONOS import rules.
*
* @param importInfo the set of classes/interfaces to be imported.
* @return string of import info.
*/
public List<ImportInfo> sortImportOrder(SortedSet<ImportInfo> importInfo) {
/* TODO: reorder the import list based on the ONOS import rules. */
return null;
}
/**
* Get the textual java code information corresponding to the import list.
*
* @param importInfo import info.
......
......@@ -113,7 +113,6 @@ public final class MethodsGenerator {
GeneratedMethodTypes methodTypes, YangType<?> returnType) {
if (returnType == null) {
@SuppressWarnings("rawtypes")
YangType<?> type = new YangType();
type.setDataTypeName(yangName);
returnType = type;
......
......@@ -62,7 +62,8 @@ public final class FileSystemUtil {
public static void createPackage(String pkg, String pkgInfo) throws IOException {
if (!doesPackageExist(new File(pkg))) {
try {
File pack = YangIoUtils.createDirectories(pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH));
File pack = YangIoUtils
.createDirectories(pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH));
YangIoUtils.addPackageInfo(pack, pkgInfo, pkg);
} catch (IOException e) {
throw new IOException("failed to create package-info file");
......
......@@ -22,8 +22,8 @@ import org.onosproject.yangutils.parser.exceptions.ParserException;
/**
* ExpectedException framework can use the Hamcrest matcher's to test
* custom/extended exceptions. This class extends the type safe matcher to define
* the custom exception matcher.
* custom/extended exceptions. This class extends the type safe matcher to
* define the custom exception matcher.
*/
public final class CustomExceptionMatcher extends TypeSafeMatcher<ParserException> {
......
......@@ -16,25 +16,24 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangStatusType;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -66,8 +65,8 @@ public class ConfigListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether the Config value is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -92,8 +91,8 @@ public class ConfigListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether the Config value is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -167,8 +166,8 @@ public class ConfigListenerTest {
assertThat(container.isConfig(), is(true));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -203,8 +202,8 @@ public class ConfigListenerTest {
assertThat(yangList.isConfig(), is(true));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -234,8 +233,8 @@ public class ConfigListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeafList<?>> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
// Check whether config value is set correctly.
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
......
......@@ -16,24 +16,23 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangStatusType;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -154,8 +153,8 @@ public class ContainerListenerTest {
assertThat(yangContainer.getReference(), is("\"container reference\""));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = yangContainer.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangContainer.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......
......@@ -16,25 +16,24 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangStatusType;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -66,8 +65,8 @@ public class DescriptionListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether the description is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -175,8 +174,8 @@ public class DescriptionListenerTest {
assertThat(container.getDescription(), is("\"container description\""));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -212,8 +211,8 @@ public class DescriptionListenerTest {
assertThat(yangList.getDescription(), is("\"list description\""));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -243,8 +242,8 @@ public class DescriptionListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeafList<?>> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
// Check whether description value is set correctly.
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
......
......@@ -16,24 +16,23 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangStatusType;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -48,8 +47,7 @@ public class LeafListListenerTest {
private final YangUtilsParserManager manager = new YangUtilsParserManager();
/**
* Checks all the values of leaf-list sub-statements are set
* correctly.
* Checks all the values of leaf-list sub-statements are set correctly.
*/
@Test
public void processLeafListSubStatements() throws IOException, ParserException {
......@@ -66,8 +64,8 @@ public class LeafListListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeafList<?>> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -81,8 +79,8 @@ public class LeafListListenerTest {
}
/**
* Checks whether exception is thrown when leaf-list identifier
* starts with digit.
* Checks whether exception is thrown when leaf-list identifier starts with
* digit.
*/
@Test
public void processLeafListInvalidIdentifier() throws IOException, ParserException {
......@@ -92,8 +90,7 @@ public class LeafListListenerTest {
}
/**
* Checks whether exception is thrown when leaf-list keyword
* is incorrect.
* Checks whether exception is thrown when leaf-list keyword is incorrect.
*/
@Test
public void processLeafListInvalidStatement() throws IOException, ParserException {
......@@ -106,8 +103,8 @@ public class LeafListListenerTest {
}
/**
* Checks whether exception is thrown when leaf-list keyword
* without Left brace as per grammar.
* Checks whether exception is thrown when leaf-list keyword without Left
* brace as per grammar.
*/
@Test
public void processLeafListWithoutLeftBrace() throws IOException, ParserException {
......@@ -117,8 +114,8 @@ public class LeafListListenerTest {
}
/**
* Checks whether exception is thrown when config statement
* cardinality is not as per grammar.
* Checks whether exception is thrown when config statement cardinality is
* not as per grammar.
*/
@Test
public void processLeafListConfigInvalidCardinality() throws IOException, ParserException {
......@@ -128,8 +125,8 @@ public class LeafListListenerTest {
}
/**
* Checks whether exception is thrown when units statement
* cardinality is not as per grammar.
* Checks whether exception is thrown when units statement cardinality is
* not as per grammar.
*/
@Test
public void processLeafListUnitsInvalidCardinality() throws IOException, ParserException {
......@@ -161,8 +158,8 @@ public class LeafListListenerTest {
assertThat(container.getName(), is("valid"));
// Check whether leaf-list properties as set correctly.
ListIterator<YangLeafList<?>> leafListIterator = container.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = container.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -198,8 +195,8 @@ public class LeafListListenerTest {
assertThat(yangList.getName(), is("valid"));
// Check whether leaf-list properties as set correctly.
ListIterator<YangLeafList<?>> leafListIterator = yangList.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = yangList.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......
......@@ -16,24 +16,23 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangStatusType;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -48,8 +47,7 @@ public class LeafListenerTest {
private final YangUtilsParserManager manager = new YangUtilsParserManager();
/**
* Checks all the values of leaf sub-statements are set
* correctly.
* Checks all the values of leaf sub-statements are set correctly.
*/
@Test
public void processLeafSubStatements() throws IOException, ParserException {
......@@ -66,8 +64,8 @@ public class LeafListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -81,8 +79,8 @@ public class LeafListenerTest {
}
/**
* Checks whether exception is thrown when leaf identifier
* starts with digit.
* Checks whether exception is thrown when leaf identifier starts with
* digit.
*/
@Test
public void processLeafInvalidIdentifier() throws IOException, ParserException {
......@@ -92,8 +90,7 @@ public class LeafListenerTest {
}
/**
* Checks whether exception is thrown when leaf keyword
* is incorrect.
* Checks whether exception is thrown when leaf keyword is incorrect.
*/
@Test
public void processLeafInvalidStatement() throws IOException, ParserException {
......@@ -106,8 +103,8 @@ public class LeafListenerTest {
}
/**
* Checks whether exception is thrown when leaf keyword
* without Left brace as per grammar.
* Checks whether exception is thrown when leaf keyword without Left brace
* as per grammar.
*/
@Test
public void processLeafWithoutLeftBrace() throws IOException, ParserException {
......@@ -117,8 +114,8 @@ public class LeafListenerTest {
}
/**
* Checks whether exception is thrown when config statement
* cardinality is not as per grammar.
* Checks whether exception is thrown when config statement cardinality is
* not as per grammar.
*/
@Test
public void processLeafConfigInvalidCardinality() throws IOException, ParserException {
......@@ -128,8 +125,8 @@ public class LeafListenerTest {
}
/**
* Checks whether exception is thrown when mandatory statement
* cardinality is not as per grammar.
* Checks whether exception is thrown when mandatory statement cardinality
* is not as per grammar.
*/
@Test
public void processLeafMandatoryInvalidCardinality() throws IOException, ParserException {
......@@ -161,8 +158,8 @@ public class LeafListenerTest {
assertThat(container.getName(), is("valid"));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -197,8 +194,8 @@ public class LeafListenerTest {
assertThat(yangList.getName(), is("valid"));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......
......@@ -16,24 +16,23 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangStatusType;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -159,8 +158,8 @@ public class ListListenerTest {
assertThat(yangList.getReference(), is("\"list reference\""));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......
......@@ -16,19 +16,19 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -60,8 +60,8 @@ public class MandatoryListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether the mandatory value is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -86,8 +86,8 @@ public class MandatoryListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether the mandatory value is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -112,8 +112,8 @@ public class MandatoryListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether the mandatory value is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -131,7 +131,8 @@ public class MandatoryListenerTest {
}
/**
* Checks invalid mandatory statement(without statement end) and expects exception.
* Checks invalid mandatory statement(without statement end) and expects
* exception.
*/
@Test
public void processMandatoryWithoutStatementEnd() throws IOException, ParserException {
......@@ -141,7 +142,8 @@ public class MandatoryListenerTest {
}
/**
* Checks mandatory statement as sub-statement of module and expects exception.
* Checks mandatory statement as sub-statement of module and expects
* exception.
*/
@Test
public void processModuleSubStatementMandatory() throws IOException, ParserException {
......
......@@ -16,21 +16,20 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -62,8 +61,8 @@ public class MaxElementsListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeafList<?>> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getMaxElelements(), is(3));
......@@ -93,8 +92,8 @@ public class MaxElementsListenerTest {
}
/**
* Checks whether exception is thrown when invalid max-elements keyword
* is given as input.
* Checks whether exception is thrown when invalid max-elements keyword is
* given as input.
*/
@Test
public void processMaxElementsInvalidStatement() throws IOException, ParserException {
......@@ -106,8 +105,8 @@ public class MaxElementsListenerTest {
}
/**
* Checks whether exception is thrown when max-elements statement without statement
* end is given as input.
* Checks whether exception is thrown when max-elements statement without
* statement end is given as input.
*/
@Test
public void processMaxElementsWithoutStatementEnd() throws IOException, ParserException {
......@@ -145,8 +144,8 @@ public class MaxElementsListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeafList<?>> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getMaxElelements(), is(2147483647));
......
......@@ -16,21 +16,20 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -62,8 +61,8 @@ public class MinElementsListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeafList<?>> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getMinElements(), is(3));
......@@ -93,8 +92,8 @@ public class MinElementsListenerTest {
}
/**
* Checks whether exception is thrown when invalid min-elements keyword
* is given as input.
* Checks whether exception is thrown when invalid min-elements keyword is
* given as input.
*/
@Test
public void processMinElementsInvalidKeyword() throws IOException, ParserException {
......@@ -106,8 +105,8 @@ public class MinElementsListenerTest {
}
/**
* Checks whether exception is thrown when invalid min-elements value
* is given as input.
* Checks whether exception is thrown when invalid min-elements value is
* given as input.
*/
@Test
public void processMinElementsInvalidValue() throws IOException, ParserException {
......@@ -117,8 +116,8 @@ public class MinElementsListenerTest {
}
/**
* Checks whether exception is thrown when min-elements statement without statement
* end is given as input.
* Checks whether exception is thrown when min-elements statement without
* statement end is given as input.
*/
@Test
public void processMinElementsWithoutStatementEnd() throws IOException, ParserException {
......
......@@ -16,25 +16,24 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangStatusType;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -66,8 +65,8 @@ public class ReferenceListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether the reference is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -174,8 +173,8 @@ public class ReferenceListenerTest {
assertThat(container.getReference(), is("\"container reference\""));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -211,8 +210,8 @@ public class ReferenceListenerTest {
assertThat(yangList.getReference(), is("\"list reference\""));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -242,8 +241,8 @@ public class ReferenceListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeafList<?>> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
// Check whether description value is set correctly.
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
......
......@@ -16,25 +16,24 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangStatusType;
import org.onosproject.yangutils.datamodel.YangContainer;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -66,8 +65,8 @@ public class StatusListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether the status is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -92,8 +91,8 @@ public class StatusListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether the status is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -118,8 +117,8 @@ public class StatusListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether the status is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -184,8 +183,8 @@ public class StatusListenerTest {
assertThat(container.getStatus(), is(YangStatusType.OBSOLETE));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -221,8 +220,8 @@ public class StatusListenerTest {
assertThat(yangList.getStatus(), is(YangStatusType.CURRENT));
// Check whether leaf properties as set correctly.
ListIterator<YangLeaf<?>> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -252,8 +251,8 @@ public class StatusListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeafList<?>> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
// Check whether status is set correctly.
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
......
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Test;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangDataTypes;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
......@@ -41,8 +41,8 @@ public class TypeListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"hello\""));
......@@ -67,8 +67,8 @@ public class TypeListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......@@ -93,8 +93,8 @@ public class TypeListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeafList<?>> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
......
......@@ -16,25 +16,24 @@
package org.onosproject.yangutils.parser.impl.listeners;
import java.io.IOException;
import java.util.ListIterator;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.YangNodeType;
import org.onosproject.yangutils.datamodel.YangStatusType;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import java.io.IOException;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
/**
* Test cases for units listener.
......@@ -64,8 +63,8 @@ public class UnitsListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether units value is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -113,8 +112,8 @@ public class UnitsListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
// Check whether leaf properties is set correctly.
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
......@@ -145,8 +144,8 @@ public class UnitsListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeaf<?>> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf<?> leafInfo = leafIterator.next();
ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
YangLeaf leafInfo = leafIterator.next();
assertThat(leafInfo.getLeafName(), is("invalid-interval"));
assertThat(leafInfo.getUnits(), is(nullValue()));
......@@ -180,8 +179,8 @@ public class UnitsListenerTest {
YangModule yangNode = (YangModule) node;
assertThat(yangNode.getName(), is("Test"));
ListIterator<YangLeafList<?>> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList<?> leafListInfo = leafListIterator.next();
ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
YangLeafList leafListInfo = leafListIterator.next();
// Check whether units value is set correctly.
assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
......