Gaurav Agrawal
Committed by Gerrit Code Review

YANG construct collision detection framework added

Change-Id: I1458f9e3192641f3f90c444798c31a64536ffa5d
Showing 89 changed files with 957 additions and 826 deletions
/*
* 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.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.utils.YangConstructType;
/**
* Abstraction of YANG collision function. Abstracted to unify the collision
* detection functionality.
*/
public interface CollisionDetector {
/**
* Checks for the colliding child.
*
* @param identifierName name of identifier for which collision to be
* checked
* @param dataType type of the YANG construct for which collision to be
* checked
* @throws DataModelException if there is any collision in YANG rules in
* parsed data, corresponding exception should be thrown
*/
void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException;
/**
* Check for the self collision.
*
* @param identifierName name of identifier for which collision to be
* checked
* @param dataType type of the YANG construct for which collision to be
* checked
* @throws DataModelException if there is any collision in YANG rules in
* parsed data, corresponding exception should be thrown
*/
void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException;
}
......@@ -20,7 +20,7 @@ import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.translator.CachedFileHandle;
/*-
......@@ -85,7 +85,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
private String targetNode;
/**
* description of augment.
* Description of augment.
*/
private String description;
......@@ -100,7 +100,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
private List<YangLeafList> listOfLeafList;
/**
* reference.
* Reference of the YANG augment.
*/
private String reference;
......@@ -110,7 +110,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
private YangStatusType status;
/**
* package of the generated java code.
* Package of the generated java code.
*/
private String pkg;
......@@ -124,7 +124,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Get the augmented node.
*
* @return the augmented node.
* @return the augmented node
*/
public String getTargetNode() {
return targetNode;
......@@ -133,7 +133,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Set the augmented node.
*
* @param targetNode the augmented node.
* @param targetNode the augmented node
*/
public void setTargetNode(String targetNode) {
this.targetNode = targetNode;
......@@ -142,7 +142,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -152,7 +152,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -162,7 +162,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Get the list of leaves.
*
* @return the list of leaves.
* @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
......@@ -172,7 +172,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Set the list of leaves.
*
* @param leafsList the list of leaf to set.
* @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
......@@ -181,7 +181,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Add a leaf.
*
* @param leaf the leaf to be added.
* @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
......@@ -195,7 +195,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Get the list of leaf-list.
*
* @return the list of leaf-list.
* @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
......@@ -205,7 +205,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Set the list of leaf-list.
*
* @param listOfLeafList the list of leaf-list to set.
* @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
......@@ -214,7 +214,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Add a leaf-list.
*
* @param leafList the leaf-list to be added.
* @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
......@@ -228,7 +228,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -238,7 +238,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -248,7 +248,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Get the status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -258,7 +258,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -268,17 +268,17 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Returns the type of the data as belongs-to.
*
* @return returns AUGMENT_DATA.
* @return returns AUGMENT_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.AUGMENT_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.AUGMENT_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -288,7 +288,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......@@ -298,7 +298,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Get the target nodes name where the augmentation is being done.
*
* @return target nodes name where the augmentation is being done.
* @return target nodes name where the augmentation is being done
*/
@Override
public String getName() {
......@@ -308,7 +308,7 @@ public class YangAugment extends YangNode implements YangLeavesHolder, YangCommo
/**
* Set the target nodes name where the augmentation is being done.
*
* @param name 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) {
......
......@@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*-
* Reference 6020.
......@@ -94,7 +94,7 @@ public class YangBelongsTo implements Parsable {
/**
* Get the prefix.
*
* @return the prefix.
* @return the prefix
*/
public String getPrefix() {
return prefix;
......@@ -115,14 +115,14 @@ public class YangBelongsTo implements Parsable {
* @return ParsedDataType returns BELONGS_TO_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.BELONGS_TO_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.BELONGS_TO_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -132,7 +132,7 @@ public class YangBelongsTo implements Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
import java.util.Objects;
......@@ -83,7 +83,7 @@ public class YangBit implements YangCommonInfo, Parsable {
/**
* Returns bit name.
*
* @return the bit name.
* @return the bit name
*/
public String getBitName() {
return bitName;
......@@ -92,7 +92,7 @@ public class YangBit implements YangCommonInfo, Parsable {
/**
* Set the bit name.
*
* @param bitName the bit name to set.
* @param bitName the bit name to set
*/
public void setBitName(String bitName) {
this.bitName = bitName;
......@@ -101,7 +101,7 @@ public class YangBit implements YangCommonInfo, Parsable {
/**
* Returns description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -111,7 +111,7 @@ public class YangBit implements YangCommonInfo, Parsable {
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -121,7 +121,7 @@ public class YangBit implements YangCommonInfo, Parsable {
/**
* Returns textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -131,7 +131,7 @@ public class YangBit implements YangCommonInfo, Parsable {
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -141,7 +141,7 @@ public class YangBit implements YangCommonInfo, Parsable {
/**
* Returns status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -151,7 +151,7 @@ public class YangBit implements YangCommonInfo, Parsable {
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -170,7 +170,7 @@ public class YangBit implements YangCommonInfo, Parsable {
/**
* Set the bit position.
*
* @param position the position to set.
* @param position the position to set
*/
public void setPosition(int position) {
this.position = position;
......@@ -182,8 +182,8 @@ public class YangBit implements YangCommonInfo, Parsable {
* @return ParsedDataType returns BIT_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.BIT_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.BIT_DATA;
}
@Override
......@@ -206,7 +206,7 @@ public class YangBit implements YangCommonInfo, Parsable {
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -216,7 +216,7 @@ public class YangBit implements YangCommonInfo, Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -21,7 +21,7 @@ import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference RFC 6020.
......@@ -70,12 +70,13 @@ public class YangBits implements Parsable {
/**
* Add bit info.
*
* @param bitInfo the bit information to be added.
* @throws DataModelException due to violation in data model rules.
* @param bitInfo the bit information to be added
* @throws DataModelException due to violation in data model rules
*/
public void addBitInfo(YangBit bitInfo) throws DataModelException {
if (!getBitSet().add(bitInfo)) {
throw new DataModelException("YANG Bit already exists");
throw new DataModelException("YANG file error: Duplicate identifier detected, same as bit \""
+ bitInfo.getBitName() + "\"");
}
}
......@@ -85,14 +86,14 @@ public class YangBits implements Parsable {
* @return ParsedDataType returns BITS_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.BITS_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.BITS_DATA;
}
/**
* Returns the bits name.
*
* @return name of the bits.
* @return name of the bits
*/
public String getBitsName() {
return bitsName;
......@@ -101,7 +102,7 @@ public class YangBits implements Parsable {
/**
* Set bits name.
*
* @param bitsName bit name to be set.
* @param bitsName bit name to be set
*/
public void setBitsName(String bitsName) {
this.bitsName = bitsName;
......@@ -110,7 +111,7 @@ public class YangBits implements Parsable {
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -120,7 +121,7 @@ public class YangBits implements Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -15,13 +15,15 @@
*/
package org.onosproject.yangutils.datamodel;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.translator.CachedFileHandle;
import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.utils.YangConstructType.CASE_DATA;
import java.util.LinkedList;
import java.util.List;
/*-
* Reference RFC 6020.
......@@ -90,7 +92,7 @@ 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 {
implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector {
/**
* Case name.
......@@ -100,7 +102,7 @@ public class YangCase extends YangNode
// TODO: default field identification for the case
/**
* Description of container.
* Description of case.
*/
private String description;
......@@ -125,7 +127,7 @@ public class YangCase extends YangNode
private YangStatusType status;
/**
* package of the generated java code.
* Package of the generated java code.
*/
private String pkg;
......@@ -139,7 +141,7 @@ public class YangCase extends YangNode
/**
* Get the case name.
*
* @return case name.
* @return case name
*/
@Override
public String getName() {
......@@ -149,7 +151,7 @@ public class YangCase extends YangNode
/**
* Set the case name.
*
* @param name case name.
* @param name case name
*/
@Override
public void setName(String name) {
......@@ -159,7 +161,7 @@ public class YangCase extends YangNode
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -169,7 +171,7 @@ public class YangCase extends YangNode
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -179,7 +181,7 @@ public class YangCase extends YangNode
/**
* Get the list of leaves.
*
* @return the list of leaves.
* @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
......@@ -189,7 +191,7 @@ public class YangCase extends YangNode
/**
* Set the list of leaves.
*
* @param leafsList the list of leaf to set.
* @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
......@@ -198,7 +200,7 @@ public class YangCase extends YangNode
/**
* Add a leaf.
*
* @param leaf the leaf to be added.
* @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
......@@ -212,7 +214,7 @@ public class YangCase extends YangNode
/**
* Get the list of leaf-list.
*
* @return the list of leaf-list.
* @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
......@@ -222,7 +224,7 @@ public class YangCase extends YangNode
/**
* Set the list of leaf-list.
*
* @param listOfLeafList the list of leaf-list to set.
* @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
......@@ -231,7 +233,7 @@ public class YangCase extends YangNode
/**
* Add a leaf-list.
*
* @param leafList the leaf-list to be added.
* @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
......@@ -245,7 +247,7 @@ public class YangCase extends YangNode
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -255,7 +257,7 @@ public class YangCase extends YangNode
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -265,7 +267,7 @@ public class YangCase extends YangNode
/**
* Get the status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -275,7 +277,7 @@ public class YangCase extends YangNode
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -288,14 +290,14 @@ public class YangCase extends YangNode
* @return returns CASE_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.CASE_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.CASE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -305,7 +307,7 @@ public class YangCase extends YangNode
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......@@ -361,6 +363,30 @@ public class YangCase extends YangNode
@Override
public void setFileHandle(CachedFileHandle fileHandle) {
// TODO Auto-generated method stub
}
@Override
public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
if ((this.getParent() == null) || (!(this.getParent() instanceof YangChoice))) {
throw new DataModelException("Internal Data Model Tree Error: Invalid/Missing holder in case " +
this.getName());
}
// Traverse up in tree to ask parent choice start collision detection.
((CollisionDetector) this.getParent()).detectCollidingChild(identifierName, dataType);
}
@Override
public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
if (dataType == CASE_DATA) {
if (this.getName().equals(identifierName)) {
throw new DataModelException("YANG File Error: Identifier collision detected in case \"" +
this.getName() + "\"");
}
return;
}
// Asks helper to detect colliding child.
detectCollidingChildUtil(identifierName, dataType, this);
}
}
......
......@@ -15,13 +15,11 @@
*/
package org.onosproject.yangutils.datamodel;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.translator.CachedFileHandle;
import org.onosproject.yangutils.utils.YangConstructType;
import static org.onosproject.yangutils.utils.YangConstructType.CHOICE_DATA;
/*-
* Reference RFC 6020.
......@@ -61,7 +59,7 @@ import org.onosproject.yangutils.translator.CachedFileHandle;
/**
* Data model node to maintain information defined in YANG choice.
*/
public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
public class YangChoice extends YangNode implements YangCommonInfo, Parsable, CollisionDetector {
/**
* Name of choice.
......@@ -69,11 +67,6 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
private String name;
/**
* List of cases for the current choice.
*/
private List<YangCase> caseList;
/**
* If the choice represents config data.
*/
private boolean isConfig;
......@@ -105,7 +98,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
private String defaultCase;
/**
* Description.
* Description of choice.
*/
private String description;
......@@ -131,7 +124,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
private String mandatory;
/**
* reference of the choice.
* Reference of the choice.
*/
private String reference;
......@@ -141,13 +134,15 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
private YangStatusType status;
/**
* Create a Choice node.
* Create a choice node.
*/
public YangChoice() {
super(YangNodeType.CHOICE_NODE);
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
*/
@Override
......@@ -155,8 +150,11 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
return name;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
/*
* (non-Javadoc)
*
* @see
* org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
*/
@Override
public void setName(String name) {
......@@ -164,40 +162,9 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
}
/**
* Get the list of cases.
*
* @return the case list
*/
public List<YangCase> getCaseList() {
return caseList;
}
/**
* Set the list of cases.
*
* @param caseList list of cases.
*/
private void setCaseList(List<YangCase> caseList) {
this.caseList = caseList;
}
/**
* Add a case.
*
* @param newCase new case for the choice
*/
public void addCase(YangCase newCase) {
if (getCaseList() == null) {
setCaseList(new LinkedList<YangCase>());
}
getCaseList().add(newCase);
}
/**
* Get config flag.
*
* @return the config flag.
* @return the config flag
*/
public boolean isConfig() {
return isConfig;
......@@ -206,7 +173,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Set config flag.
*
* @param isCfg the config flag.
* @param isCfg the config flag
*/
public void setConfig(boolean isCfg) {
isConfig = isCfg;
......@@ -215,7 +182,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the default case.
*
* @return the default case.
* @return the default case
*/
public String getDefaultCase() {
return defaultCase;
......@@ -233,7 +200,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the mandatory status.
*
* @return the mandatory status.
* @return the mandatory status
*/
public String getMandatory() {
return mandatory;
......@@ -242,7 +209,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the mandatory status.
*
* @param mandatory the mandatory status.
* @param mandatory the mandatory status
*/
public void setMandatory(String mandatory) {
this.mandatory = mandatory;
......@@ -251,7 +218,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -261,7 +228,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -271,7 +238,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -281,7 +248,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -291,7 +258,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -301,7 +268,7 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -314,14 +281,14 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
* @return returns CHOICE_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.CHOICE_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.CHOICE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -331,14 +298,16 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
*/
@Override
......@@ -347,8 +316,11 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
/*
* (non-Javadoc)
*
* @see
* org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
*/
@Override
public void setPackage(String pkg) {
......@@ -356,8 +328,12 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
/*
* (non-Javadoc)
*
* @see
* org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry(
* )
*/
@Override
public void generateJavaCodeEntry() {
......@@ -365,8 +341,11 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
/*
* (non-Javadoc)
*
* @see
* org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
*/
@Override
public void generateJavaCodeExit() {
......@@ -385,4 +364,36 @@ public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
// TODO Auto-generated method stub
}
@Override
public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
YangNode node = this.getChild();
while ((node != null)) {
if (node instanceof CollisionDetector) {
((CollisionDetector) node).detectSelfCollision(identifierName, dataType);
}
node = node.getNextSibling();
}
}
@Override
public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
if (dataType == CHOICE_DATA) {
if (this.getName().equals(identifierName)) {
throw new DataModelException("YANG file error: Identifier collision detected in choice \"" +
this.getName() + "\"");
}
return;
}
YangNode node = this.getChild();
while ((node != null)) {
if (node instanceof CollisionDetector) {
((CollisionDetector) node).detectSelfCollision(identifierName, dataType);
}
node = node.getNextSibling();
}
}
}
......
......@@ -21,8 +21,9 @@ import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.translator.CachedFileHandle;
import org.onosproject.yangutils.translator.GeneratedFileType;
import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
......@@ -90,7 +91,7 @@ import org.onosproject.yangutils.utils.io.impl.FileSystemUtil;
/**
* Data model node to maintain information defined in YANG container.
*/
public class YangContainer extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable {
public class YangContainer extends YangNode implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector {
/**
* Name of the container.
......@@ -153,7 +154,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Get the YANG name of container.
*
* @return the name of container as defined in YANG file.
* @return the name of container as defined in YANG file
*/
@Override
public String getName() {
......@@ -163,7 +164,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Set the YANG name of container.
*
* @param name the name of container as defined in YANG file.
* @param name the name of container as defined in YANG file
*/
@Override
public void setName(String name) {
......@@ -182,7 +183,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Set the config flag.
*
* @param isCfg the config flag.
* @param isCfg the config flag
*/
public void setConfig(boolean isCfg) {
isConfig = isCfg;
......@@ -191,7 +192,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -201,7 +202,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -211,7 +212,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Get the list of leaves.
*
* @return the list of leaves.
* @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
......@@ -221,7 +222,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Set the list of leaves.
*
* @param leafsList the list of leaf to set.
* @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
......@@ -230,7 +231,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Add a leaf.
*
* @param leaf the leaf to be added.
* @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
......@@ -244,7 +245,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Get the list of leaf-list.
*
* @return the list of leaf-list.
* @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
......@@ -254,7 +255,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Set the list of leaf-list.
*
* @param listOfLeafList the list of leaf-list to set.
* @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
......@@ -263,7 +264,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Add a leaf-list.
*
* @param leafList the leaf-list to be added.
* @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
......@@ -277,7 +278,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Get the presence string if present.
*
* @return the isPressence.
* @return the presence
*/
public String getPresence() {
return presence;
......@@ -295,7 +296,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -305,7 +306,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -315,7 +316,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Get the status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -325,7 +326,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -355,17 +356,17 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Returns the type of the data.
*
* @return returns CONTAINER_DATA.
* @return returns CONTAINER_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.CONTAINER_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.CONTAINER_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -375,7 +376,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......@@ -387,15 +388,18 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
}
/**
* Sets the config's value to all leaf if leaf's config statement is not specified.
* Sets the config's value to all leaf if leaf's config statement is not
* specified.
*
* @param leaves list of leaf attributes of container.
* @param leafLists list of leaf-list attributes of container.
* @param leaves list of leaf attributes of container
* @param leafLists list of leaf-list attributes of container
*/
private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) {
/* If "config" is not specified, the default is the same as the parent
schema node's "config" value.*/
/*
* If "config" is not specified, the default is the same as the parent
* schema node's "config" value.
*/
if (leaves != null) {
for (YangLeaf leaf : leaves) {
if (leaf.isConfig() == null) {
......@@ -404,8 +408,10 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
}
}
/* If "config" is not specified, the default is the same as the parent
schema node's "config" value.*/
/*
* If "config" is not specified, the default is the same as the parent
* schema node's "config" value.
*/
if (leafLists != null) {
for (YangLeafList leafList : leafLists) {
if (leafList.isConfig() == null) {
......@@ -418,14 +424,16 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Validates config statement of container.
*
* @param leaves list of leaf attributes of container.
* @param leafLists list of leaf-list attributes of container.
* @throws DataModelException a violation of data model rules.
* @param leaves list of leaf attributes of container
* @param leafLists list of leaf-list attributes of container
* @throws DataModelException a violation of data model rules
*/
private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException {
/* If a node has "config" set to "false", no node underneath it can have
"config" set to "true".*/
/*
* If a node has "config" set to "false", no node underneath it can have
* "config" set to "true".
*/
if ((!isConfig) && (leaves != null)) {
for (YangLeaf leaf : leaves) {
if (leaf.isConfig()) {
......@@ -468,7 +476,7 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
/**
* Generate the java code corresponding to YANG container.
*
* @throws IOException when fails to generate the source files.
* @throws IOException when fails to generate the source files
*/
@Override
public void generateJavaCodeEntry() throws IOException {
......@@ -532,4 +540,18 @@ public class YangContainer extends YangNode implements YangLeavesHolder, YangCom
}
return;
}
@Override
public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
// Asks helper to detect colliding child.
detectCollidingChildUtil(identifierName, dataType, this);
}
@Override
public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
if (this.getName().equals(identifierName)) {
throw new DataModelException("YANG file error: Duplicate input identifier detected, same as container \""
+ this.getName() + "\"");
}
}
}
......
......@@ -15,7 +15,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*-
* The typedef Statement
......@@ -60,7 +60,7 @@ public class YangDerivedType implements Parsable {
/**
* Get the effective YANG built-in type of the derived data type.
*
* @return effective YANG built-in type of the derived data type.
* @return effective YANG built-in type of the derived data type
*/
public YangDataTypes getEffectiveYangBuiltInType() {
return effectiveYangBuiltInType;
......@@ -69,7 +69,7 @@ public class YangDerivedType implements Parsable {
/**
* Set the effective YANG built-in type of the derived data type.
*
* @param builtInType effective YANG built-in type of the derived data type.
* @param builtInType effective YANG built-in type of the derived data type
*/
public void setEffectiveYangBuiltInType(YangDataTypes builtInType) {
effectiveYangBuiltInType = builtInType;
......@@ -78,7 +78,7 @@ public class YangDerivedType implements Parsable {
/**
* Get the base type information.
*
* @return base type information.
* @return base type information
*/
public YangType<?> getBaseType() {
return baseType;
......@@ -87,7 +87,7 @@ public class YangDerivedType implements Parsable {
/**
* Get the base type information.
*
* @param baseType base type information.
* @param baseType base type information
*/
public void setBaseType(YangType<?> baseType) {
this.baseType = baseType;
......@@ -97,8 +97,8 @@ public class YangDerivedType implements Parsable {
* Get the parsable type.
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.DERIVED;
public YangConstructType getYangConstructType() {
return YangConstructType.DERIVED;
}
/**
......
......@@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
import java.util.Objects;
......@@ -73,7 +73,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
private YangStatusType status;
/**
* value of ENUM.
* Value of ENUM.
*/
private int value;
......@@ -87,7 +87,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Get the named value.
*
* @return the named value.
* @return the named value
*/
public String getNamedValue() {
return namedValue;
......@@ -96,7 +96,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Set the named value.
*
* @param namedValue the named value to set.
* @param namedValue the named value to set
*/
public void setNamedValue(String namedValue) {
this.namedValue = namedValue;
......@@ -105,7 +105,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -115,7 +115,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -125,7 +125,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -135,7 +135,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -145,7 +145,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Get the status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -155,7 +155,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -165,7 +165,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Get the value.
*
* @return the value.
* @return the value
*/
public int getValue() {
return value;
......@@ -174,7 +174,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Set the value.
*
* @param value the value to set.
* @param value the value to set
*/
public void setValue(int value) {
this.value = value;
......@@ -186,8 +186,8 @@ public class YangEnum implements YangCommonInfo, Parsable {
* @return ParsedDataType returns ENUM_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.ENUM_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.ENUM_DATA;
}
@Override
......@@ -210,7 +210,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -220,7 +220,7 @@ public class YangEnum implements YangCommonInfo, Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -21,7 +21,7 @@ import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*
* The enumeration built-in type represents values from a set of
......@@ -67,8 +67,8 @@ public class YangEnumeration implements Parsable {
/**
* Add ENUM information.
*
* @param enumInfo the ENUM information to be added.
* @throws DataModelException due to violation in data model rules.
* @param enumInfo the ENUM information to be added
* @throws DataModelException due to violation in data model rules
*/
public void addEnumInfo(YangEnum enumInfo) throws DataModelException {
if (!getEnumSet().add(enumInfo)) {
......@@ -100,14 +100,14 @@ public class YangEnumeration implements Parsable {
* @return returns ENUMERATION_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.ENUMERATION_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.ENUMERATION_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -117,7 +117,7 @@ public class YangEnumeration implements Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -20,7 +20,7 @@ import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.translator.CachedFileHandle;
/*-
......@@ -110,7 +110,7 @@ public class YangGrouping extends YangNode
private YangStatusType status;
/**
* package of the generated java code.
* Package of the generated java code.
*/
private String pkg;
......@@ -124,7 +124,7 @@ public class YangGrouping extends YangNode
/**
* Get YANG grouping name.
*
* @return YANG grouping name.
* @return YANG grouping name
*/
@Override
public String getName() {
......@@ -134,7 +134,7 @@ public class YangGrouping extends YangNode
/**
* Set YANG grouping name.
*
* @param name YANG grouping name.
* @param name YANG grouping name
*/
@Override
public void setName(String name) {
......@@ -144,7 +144,7 @@ public class YangGrouping extends YangNode
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -154,7 +154,7 @@ public class YangGrouping extends YangNode
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -164,7 +164,7 @@ public class YangGrouping extends YangNode
/**
* Get the list of leaves.
*
* @return the list of leaves.
* @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
......@@ -174,7 +174,7 @@ public class YangGrouping extends YangNode
/**
* Set the list of leaves.
*
* @param leafsList the list of leaf to set.
* @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
......@@ -183,7 +183,7 @@ public class YangGrouping extends YangNode
/**
* Add a leaf.
*
* @param leaf the leaf to be added.
* @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
......@@ -197,7 +197,7 @@ public class YangGrouping extends YangNode
/**
* Get the list of leaf-list.
*
* @return the list of leaf-list.
* @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
......@@ -207,7 +207,7 @@ public class YangGrouping extends YangNode
/**
* Set the list of leaf-list.
*
* @param listOfLeafList the list of leaf-list to set.
* @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
......@@ -216,7 +216,7 @@ public class YangGrouping extends YangNode
/**
* Add a leaf-list.
*
* @param leafList the leaf-list to be added.
* @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
......@@ -230,7 +230,7 @@ public class YangGrouping extends YangNode
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -240,7 +240,7 @@ public class YangGrouping extends YangNode
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -250,7 +250,7 @@ public class YangGrouping extends YangNode
/**
* Get the status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -260,7 +260,7 @@ public class YangGrouping extends YangNode
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -270,17 +270,17 @@ public class YangGrouping extends YangNode
/**
* Returns the type of the data.
*
* @return returns GROUPING_DATA.
* @return returns GROUPING_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.GROUPING_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.GROUPING_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -290,7 +290,7 @@ public class YangGrouping extends YangNode
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
......@@ -94,7 +94,7 @@ public class YangImport implements Parsable {
/**
* Get the imported module name.
*
* @return the module name.
* @return the module name
*/
public String getModuleName() {
return name;
......@@ -113,7 +113,7 @@ public class YangImport implements Parsable {
* Get the prefix used to identify the entities from the imported module.
*
* @return the prefix used to identify the entities from the imported
* module.
* module
*/
public String getPrefixId() {
return prefixId;
......@@ -122,7 +122,7 @@ public class YangImport implements Parsable {
/**
* Set prefix identifier.
*
* @param prefixId set the prefix identifier of the imported module.
* @param prefixId set the prefix identifier of the imported module
*/
public void setPrefixId(String prefixId) {
this.prefixId = prefixId;
......@@ -131,7 +131,7 @@ public class YangImport implements Parsable {
/**
* Get the revision of the imported module.
*
* @return the revision of the imported module.
* @return the revision of the imported module
*/
public String getRevision() {
return revision;
......@@ -140,7 +140,7 @@ public class YangImport implements Parsable {
/**
* Set the revision of the imported module.
*
* @param rev set the revision of the imported module.
* @param rev set the revision of the imported module
*/
public void setRevision(String rev) {
revision = rev;
......@@ -152,8 +152,8 @@ public class YangImport implements Parsable {
* @return returns IMPORT_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.IMPORT_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.IMPORT_DATA;
}
/**
......
......@@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
......@@ -98,8 +98,8 @@ public class YangInclude implements Parsable {
* @return returns INCLUDE_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.INCLUDE_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.INCLUDE_DATA;
}
/**
......
......@@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
......@@ -108,7 +108,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Get the name of leaf.
*
* @return the leaf name.
* @return the leaf name
*/
public String getLeafName() {
return name;
......@@ -117,7 +117,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Set the name of leaf.
*
* @param leafName the leaf name to set.
* @param leafName the leaf name to set
*/
public void setLeafName(String leafName) {
name = leafName;
......@@ -126,7 +126,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Get the config flag.
*
* @return if config flag.
* @return if config flag
*/
public Boolean isConfig() {
return isConfig;
......@@ -135,7 +135,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Set the config flag.
*
* @param isCfg the flag value to set.
* @param isCfg the flag value to set
*/
public void setConfig(boolean isCfg) {
isConfig = isCfg;
......@@ -144,7 +144,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -154,7 +154,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -164,7 +164,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Get if the leaf is mandatory.
*
* @return if leaf is mandatory.
* @return if leaf is mandatory
*/
public boolean isMandatory() {
return isMandatory;
......@@ -182,7 +182,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -192,7 +192,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -202,7 +202,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Get the status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -212,7 +212,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -222,7 +222,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Get the units.
*
* @return the units.
* @return the units
*/
public String getUnits() {
return units;
......@@ -231,7 +231,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Set the units.
*
* @param units the units to set.
* @param units the units to set
*/
public void setUnits(String units) {
this.units = units;
......@@ -240,7 +240,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Get the data type.
*
* @return the data type.
* @return the data type
*/
public YangType<?> getDataType() {
return dataType;
......@@ -249,7 +249,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Set the data type.
*
* @param dataType the data type to set.
* @param dataType the data type to set
*/
public void setDataType(YangType<?> dataType) {
this.dataType = dataType;
......@@ -258,17 +258,17 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Returns the type of the parsed data.
*
* @return returns LEAF_DATA.
* @return returns LEAF_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.LEAF_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.LEAF_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -279,7 +279,7 @@ public class YangLeaf implements YangCommonInfo, Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
......@@ -130,7 +130,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Get the leaf-list name.
*
* @return the leaf-list name.
* @return the leaf-list name
*/
public String getLeafName() {
return name;
......@@ -139,7 +139,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Set the leaf-list name.
*
* @param leafListName the leaf-list name to set.
* @param leafListName the leaf-list name to set
*/
public void setLeafName(String leafListName) {
name = leafListName;
......@@ -148,7 +148,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Get the config flag.
*
* @return the config flag.
* @return the config flag
*/
public Boolean isConfig() {
return isConfig;
......@@ -157,7 +157,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Set the config flag.
*
* @param isCfg the config flag.
* @param isCfg the config flag
*/
public void setConfig(boolean isCfg) {
isConfig = isCfg;
......@@ -166,7 +166,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -176,7 +176,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -186,7 +186,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Get the max elements no.
*
* @return the max elements no.
* @return the max elements no
*/
public int getMaxElelements() {
return maxElelements;
......@@ -195,7 +195,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Set the max elements no.
*
* @param maxElelements max elements no.
* @param maxElelements max elements no
*/
public void setMaxElelements(int maxElelements) {
this.maxElelements = maxElelements;
......@@ -204,7 +204,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Get the min elements no.
*
* @return the min elements no.
* @return the min elements no
*/
public int getMinElements() {
return minElements;
......@@ -213,7 +213,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Set the min elements no.
*
* @param minElements the min elements no.
* @param minElements the min elements no
*/
public void setMinElements(int minElements) {
this.minElements = minElements;
......@@ -222,7 +222,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -232,7 +232,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -242,7 +242,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Get the status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -252,7 +252,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -262,7 +262,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Get the units.
*
* @return the units.
* @return the units
*/
public String getUnits() {
return units;
......@@ -271,7 +271,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Set the units.
*
* @param units the units to set.
* @param units the units to set
*/
public void setUnits(String units) {
this.units = units;
......@@ -280,7 +280,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Get the data type.
*
* @return the data type.
* @return the data type
*/
public YangType<?> getDataType() {
return dataType;
......@@ -289,7 +289,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Set the data type.
*
* @param dataType the data type to set.
* @param dataType the data type to set
*/
public void setDataType(YangType<?> dataType) {
this.dataType = dataType;
......@@ -298,17 +298,17 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Returns the type of the parsed data.
*
* @return returns LEAF_LIST_DATA.
* @return returns LEAF_LIST_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.LEAF_LIST_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.LEAF_LIST_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -319,7 +319,7 @@ public class YangLeafList implements YangCommonInfo, Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -16,13 +16,14 @@
package org.onosproject.yangutils.datamodel;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.translator.CachedFileHandle;
import org.onosproject.yangutils.utils.YangConstructType;
import java.util.LinkedList;
import java.util.List;
/*-
* The "list" statement is used to define an interior data node in the
......@@ -67,10 +68,10 @@ import org.onosproject.yangutils.translator.CachedFileHandle;
* List data represented in YANG.
*/
public class YangList extends YangNode
implements YangLeavesHolder, YangCommonInfo, Parsable {
implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector {
/**
* name of the YANG list.
* Name of the YANG list.
*/
private String name;
......@@ -177,7 +178,7 @@ public class YangList extends YangNode
/**
* Get the YANG list name.
*
* @return YANG list name.
* @return YANG list name
*/
@Override
public String getName() {
......@@ -187,7 +188,7 @@ public class YangList extends YangNode
/**
* Set the YANG list name.
*
* @param name YANG list name.
* @param name YANG list name
*/
@Override
public void setName(String name) {
......@@ -206,7 +207,7 @@ public class YangList extends YangNode
/**
* Set the config flag.
*
* @param isCfg the config flag.
* @param isCfg the config flag
*/
public void setConfig(boolean isCfg) {
isConfig = isCfg;
......@@ -215,7 +216,7 @@ public class YangList extends YangNode
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -225,7 +226,7 @@ public class YangList extends YangNode
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -235,7 +236,7 @@ public class YangList extends YangNode
/**
* Get the list of key field names.
*
* @return the list of key field names.
* @return the list of key field names
*/
public List<String> getKeyList() {
return keyList;
......@@ -244,7 +245,7 @@ public class YangList extends YangNode
/**
* Set the list of key field names.
*
* @param keyList the list of key field names.
* @param keyList the list of key field names
*/
private void setKeyList(List<String> keyList) {
this.keyList = keyList;
......@@ -254,7 +255,7 @@ public class YangList extends YangNode
* Add a key field name.
*
* @param key key field name.
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
public void addKey(String key) throws DataModelException {
if (getKeyList() == null) {
......@@ -272,7 +273,7 @@ public class YangList extends YangNode
/**
* Get the list of leaves.
*
* @return the list of leaves.
* @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
......@@ -282,7 +283,7 @@ public class YangList extends YangNode
/**
* Set the list of leaves.
*
* @param leafsList the list of leaf to set.
* @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
......@@ -291,7 +292,7 @@ public class YangList extends YangNode
/**
* Add a leaf.
*
* @param leaf the leaf to be added.
* @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
......@@ -305,7 +306,7 @@ public class YangList extends YangNode
/**
* Get the list of leaf-list.
*
* @return the list of leaf-list.
* @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
......@@ -315,7 +316,7 @@ public class YangList extends YangNode
/**
* Set the list of leaf-list.
*
* @param listOfLeafList the list of leaf-list to set.
* @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
......@@ -324,7 +325,7 @@ public class YangList extends YangNode
/**
* Add a leaf-list.
*
* @param leafList the leaf-list to be added.
* @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
......@@ -338,7 +339,7 @@ public class YangList extends YangNode
/**
* Get the max elements.
*
* @return the max elements.
* @return the max elements
*/
public int getMaxElelements() {
return maxElelements;
......@@ -347,7 +348,7 @@ public class YangList extends YangNode
/**
* Set the max elements.
*
* @param maxElelements the max elements.
* @param maxElelements the max elements
*/
public void setMaxElelements(int maxElelements) {
this.maxElelements = maxElelements;
......@@ -356,7 +357,7 @@ public class YangList extends YangNode
/**
* Get the minimum elements.
*
* @return the minimum elements.
* @return the minimum elements
*/
public int getMinElements() {
return minElements;
......@@ -365,7 +366,7 @@ public class YangList extends YangNode
/**
* Set the minimum elements.
*
* @param minElements the minimum elements.
* @param minElements the minimum elements
*/
public void setMinElements(int minElements) {
this.minElements = minElements;
......@@ -374,7 +375,7 @@ public class YangList extends YangNode
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -384,7 +385,7 @@ public class YangList extends YangNode
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -394,7 +395,7 @@ public class YangList extends YangNode
/**
* Get the status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -404,7 +405,7 @@ public class YangList extends YangNode
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -414,17 +415,17 @@ public class YangList extends YangNode
/**
* Returns the type of the parsed data.
*
* @return returns LIST_DATA.
* @return returns LIST_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.LIST_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.LIST_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -434,7 +435,7 @@ public class YangList extends YangNode
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......@@ -464,8 +465,8 @@ public class YangList extends YangNode
* Sets the config's value to all leaf if leaf's config statement is not
* specified.
*
* @param leaves list of leaf attributes of YANG list.
* @param leafLists list of leaf-list attributes of YANG list.
* @param leaves list of leaf attributes of YANG list
* @param leafLists list of leaf-list attributes of YANG list
*/
private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) {
......@@ -497,9 +498,9 @@ public class YangList extends YangNode
/**
* Validates config statement of YANG list.
*
* @param leaves list of leaf attributes of YANG list.
* @param leafLists list of leaf-list attributes of YANG list.
* @throws DataModelException a violation of data model rules.
* @param leaves list of leaf attributes of YANG list
* @param leafLists list of leaf-list attributes of YANG list
* @throws DataModelException a violation of data model rules
*/
private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists) throws DataModelException {
......@@ -529,9 +530,9 @@ public class YangList extends YangNode
/**
* Validates key statement of list.
*
* @param leaves list of leaf attributes of list.
* @param keys list of key attributes of list.
* @throws DataModelException a violation of data model rules.
* @param leaves list of leaf attributes of list
* @param keys list of key attributes of list
* @throws DataModelException a violation of data model rules
*/
private void validateLeafKey(List<YangLeaf> leaves, List<String> keys) throws DataModelException {
boolean leafFound = false;
......@@ -574,9 +575,9 @@ public class YangList extends YangNode
/**
* Validates key statement of list.
*
* @param leafLists list of leaf-list attributes of list.
* @param keys list of key attributes of list.
* @throws DataModelException a violation of data model rules.
* @param leafLists list of leaf-list attributes of list
* @param keys list of key attributes of list
* @throws DataModelException a violation of data model rules
*/
private void validateLeafListKey(List<YangLeafList> leafLists, List<String> keys) throws DataModelException {
boolean leafFound = false;
......@@ -668,4 +669,18 @@ public class YangList extends YangNode
// TODO Auto-generated method stub
}
@Override
public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
// Asks helper to detect colliding child.
detectCollidingChildUtil(identifierName, dataType, this);
}
@Override
public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
if (this.getName().equals(identifierName)) {
throw new DataModelException("YANG file error: Duplicate input identifier detected, same as list \"" +
this.getName() + "\"");
}
}
}
......
......@@ -15,20 +15,21 @@
*/
package org.onosproject.yangutils.datamodel;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.translator.CachedFileHandle;
import org.onosproject.yangutils.translator.CodeGenerator;
import org.onosproject.yangutils.translator.GeneratedFileType;
import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
import org.onosproject.yangutils.utils.UtilConstants;
import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.utils.io.impl.FileSystemUtil;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
/*-
* Reference:RFC 6020.
* The "module" statement defines the module's name,
......@@ -73,7 +74,7 @@ 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 {
implements YangLeavesHolder, YangDesc, YangReference, Parsable, CodeGenerator, CollisionDetector {
/**
* Name of the module.
......@@ -588,8 +589,8 @@ public class YangModule extends YangNode
* @return returns MODULE_DATA.
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.MODULE_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.MODULE_DATA;
}
/**
......@@ -697,4 +698,15 @@ public class YangModule extends YangNode
module.addToNestedReferenceResoulutionList(node);
return;
}
@Override
public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
// Asks helper to detect colliding child.
detectCollidingChildUtil(identifierName, dataType, this);
}
@Override
public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
// Not required as module doesn't have any parent.
}
}
......
......@@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*-
* The "must" statement, which is optional, takes as an argument a string that
......@@ -59,7 +59,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
private String description;
/**
* reference string.
* Reference string.
*/
private String reference;
......@@ -72,7 +72,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
/**
* Get the constraint.
*
* @return the constraint.
* @return the constraint
*/
public String getConstratint() {
return constratint;
......@@ -90,7 +90,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -100,7 +100,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -110,7 +110,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -120,7 +120,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -133,14 +133,14 @@ public class YangMust implements YangDesc, YangReference, Parsable {
* @return returns MUST_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.MUST_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.MUST_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -150,7 +150,7 @@ public class YangMust implements YangDesc, YangReference, Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
......@@ -45,7 +45,7 @@ public class YangNameSpace implements Parsable {
/**
* Get the name space URI.
*
* @return the URI.
* @return the URI
*/
public String getUri() {
return uri;
......@@ -63,17 +63,17 @@ public class YangNameSpace implements Parsable {
/**
* Returns the type of the parsed data.
*
* @return returns NAMESPACE_DATA.
* @return returns NAMESPACE_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.NAMESPACE_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.NAMESPACE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -84,7 +84,7 @@ public class YangNameSpace implements Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
......@@ -86,7 +86,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -96,7 +96,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -106,7 +106,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -116,7 +116,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -126,17 +126,17 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
/**
* Returns the type of the parsed data.
*
* @return returns REVISION_DATA.
* @return returns REVISION_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.REVISION_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.REVISION_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -147,7 +147,7 @@ public class YangRevision implements YangDesc, YangReference, Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -15,13 +15,14 @@
*/
package org.onosproject.yangutils.datamodel;
import java.util.LinkedList;
import java.util.List;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.translator.CachedFileHandle;
import org.onosproject.yangutils.utils.YangConstructType;
import java.util.LinkedList;
import java.util.List;
/*
* Reference RFC 6020.
......@@ -74,7 +75,7 @@ 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 {
implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector {
/**
* Name of sub module.
......@@ -186,7 +187,7 @@ public class YangSubModule extends YangNode
/**
* Set the module info.
*
* @param belongsTo module info to set.
* @param belongsTo module info to set
*/
public void setBelongsTo(YangBelongsTo belongsTo) {
this.belongsTo = belongsTo;
......@@ -195,7 +196,7 @@ public class YangSubModule extends YangNode
/**
* Get the contact.
*
* @return the contact.
* @return the contact
*/
public String getContact() {
return contact;
......@@ -213,7 +214,7 @@ public class YangSubModule extends YangNode
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -223,7 +224,7 @@ public class YangSubModule extends YangNode
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -233,7 +234,7 @@ public class YangSubModule extends YangNode
/**
* Get the list of imported modules.
*
* @return the list of imported modules.
* @return the list of imported modules
*/
public List<YangImport> getImportList() {
return importList;
......@@ -242,7 +243,7 @@ public class YangSubModule extends YangNode
/**
* prevent setting the import list from outside.
*
* @param importList the import list to set.
* @param importList the import list to set
*/
private void setImportList(List<YangImport> importList) {
this.importList = importList;
......@@ -251,7 +252,7 @@ public class YangSubModule extends YangNode
/**
* Add the imported module information to the import list.
*
* @param importedModule module being imported.
* @param importedModule module being imported
*/
public void addImportedInfo(YangImport importedModule) {
......@@ -267,7 +268,7 @@ public class YangSubModule extends YangNode
/**
* Get the list of included sub modules.
*
* @return the included list of sub modules.
* @return the included list of sub modules
*/
public List<YangInclude> getIncludeList() {
return includeList;
......@@ -276,7 +277,7 @@ public class YangSubModule extends YangNode
/**
* Set the list of included sub modules.
*
* @param includeList the included list to set.
* @param includeList the included list to set
*/
private void setIncludeList(List<YangInclude> includeList) {
this.includeList = includeList;
......@@ -285,7 +286,7 @@ public class YangSubModule extends YangNode
/**
* Add the included sub module information to the include list.
*
* @param includeModule submodule being included.
* @param includeModule submodule being included
*/
public void addIncludedInfo(YangInclude includeModule) {
......@@ -300,7 +301,7 @@ public class YangSubModule extends YangNode
/**
* Get the list of leaves.
*
* @return the list of leaves.
* @return the list of leaves
*/
@Override
public List<YangLeaf> getListOfLeaf() {
......@@ -310,7 +311,7 @@ public class YangSubModule extends YangNode
/**
* Set the list of leaves.
*
* @param leafsList the list of leaf to set.
* @param leafsList the list of leaf to set
*/
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
......@@ -319,7 +320,7 @@ public class YangSubModule extends YangNode
/**
* Add a leaf.
*
* @param leaf the leaf to be added.
* @param leaf the leaf to be added
*/
@Override
public void addLeaf(YangLeaf leaf) {
......@@ -333,7 +334,7 @@ public class YangSubModule extends YangNode
/**
* Get the list of leaf-list.
*
* @return the list of leaf-list.
* @return the list of leaf-list
*/
@Override
public List<YangLeafList> getListOfLeafList() {
......@@ -343,7 +344,7 @@ public class YangSubModule extends YangNode
/**
* Set the list of leaf-list.
*
* @param listOfLeafList the list of leaf-list to set.
* @param listOfLeafList the list of leaf-list to set
*/
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
......@@ -352,7 +353,7 @@ public class YangSubModule extends YangNode
/**
* Add a leaf-list.
*
* @param leafList the leaf-list to be added.
* @param leafList the leaf-list to be added
*/
@Override
public void addLeafList(YangLeafList leafList) {
......@@ -366,7 +367,7 @@ public class YangSubModule extends YangNode
/**
* Get the sub-modules organization.
*
* @return the organization.
* @return the organization
*/
public String getOrganization() {
return organization;
......@@ -375,7 +376,7 @@ public class YangSubModule extends YangNode
/**
* Set the sub-modules organization.
*
* @param org the organization to set.
* @param org the organization to set
*/
public void setOrganization(String org) {
organization = org;
......@@ -384,7 +385,7 @@ public class YangSubModule extends YangNode
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -394,7 +395,7 @@ public class YangSubModule extends YangNode
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -404,7 +405,7 @@ public class YangSubModule extends YangNode
/**
* Get the revision.
*
* @return the revision.
* @return the revision
*/
public YangRevision getRevision() {
return revision;
......@@ -413,7 +414,7 @@ public class YangSubModule extends YangNode
/**
* Set the revision.
*
* @param revision the revision to set.
* @param revision the revision to set
*/
public void setRevision(YangRevision revision) {
this.revision = revision;
......@@ -422,7 +423,7 @@ public class YangSubModule extends YangNode
/**
* Get the version.
*
* @return the version.
* @return the version
*/
public byte getVersion() {
return version;
......@@ -431,7 +432,7 @@ public class YangSubModule extends YangNode
/**
* Set the version.
*
* @param version the version to set.
* @param version the version to set
*/
public void setVersion(byte version) {
this.version = version;
......@@ -440,17 +441,17 @@ public class YangSubModule extends YangNode
/**
* Returns the type of the parsed data.
*
* @return returns SUB_MODULE_DATA.
* @return returns SUB_MODULE_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.SUB_MODULE_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.SUB_MODULE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -460,7 +461,7 @@ public class YangSubModule extends YangNode
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......@@ -515,4 +516,15 @@ public class YangSubModule extends YangNode
// TODO Auto-generated method stub
}
@Override
public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
// Asks helper to detect colliding child.
detectCollidingChildUtil(identifierName, dataType, this);
}
@Override
public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
// Not required as module doesn't have any parent.
}
}
......
......@@ -18,7 +18,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
/*
* Reference:RFC 6020.
......@@ -77,7 +77,7 @@ public class YangType<T> implements Parsable {
/**
* Get the name of data type.
*
* @return the name of data type.
* @return the name of data type
*/
public String getDataTypeName() {
return dataTypeName;
......@@ -95,7 +95,7 @@ public class YangType<T> implements Parsable {
/**
* Get the type of data.
*
* @return the data type.
* @return the data type
*/
public YangDataTypes getDataType() {
return dataType;
......@@ -104,7 +104,7 @@ public class YangType<T> implements Parsable {
/**
* Set the type of data.
*
* @param dataType data type.
* @param dataType data type
*/
public void setDataType(YangDataTypes dataType) {
this.dataType = dataType;
......@@ -113,7 +113,7 @@ public class YangType<T> implements Parsable {
/**
* Get the data type meta data.
*
* @return the data type meta data.
* @return the data type meta data
*/
public T getDataTypeExtendedInfo() {
return dataTypeExtendedInfo;
......@@ -131,17 +131,17 @@ public class YangType<T> implements Parsable {
/**
* Returns the type of the parsed data.
*
* @return returns TYPE_DATA.
* @return returns TYPE_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.TYPE_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.TYPE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -152,7 +152,7 @@ public class YangType<T> implements Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
......@@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.translator.CachedFileHandle;
/*-
......@@ -103,7 +103,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the default value.
*
* @return the default value.
* @return the default value
*/
public String getDefaultValueInString() {
return defaultValueInString;
......@@ -112,7 +112,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the default value.
*
* @param defaultValueInString the default value.
* @param defaultValueInString the default value
*/
public void setDefaultValueInString(String defaultValueInString) {
this.defaultValueInString = defaultValueInString;
......@@ -121,7 +121,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -131,7 +131,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -141,7 +141,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -151,7 +151,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -161,7 +161,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -171,7 +171,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -181,7 +181,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the derived type.
*
* @return the derived type.
* @return the derived type
*/
public YangType<YangDerivedType> getDerivedType() {
return derivedType;
......@@ -190,7 +190,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the derived type.
*
* @param derivedType the derived type.
* @param derivedType the derived type
*/
public void setDerivedType(YangType<YangDerivedType> derivedType) {
this.derivedType = derivedType;
......@@ -220,14 +220,14 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
* @return returns TYPEDEF_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.TYPEDEF_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.TYPEDEF_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -237,7 +237,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......@@ -274,7 +274,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the YANG name of the typedef.
*
* @return YANG name of the typedef.
* @return YANG name of the typedef
*/
@Override
public String getName() {
......@@ -287,7 +287,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Set YANG name of the typedef.
*
* @param name YANG name of the typedef.
* @param name YANG name of the typedef
*/
@Override
public void setName(String name) {
......@@ -330,7 +330,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the mapped java package.
*
* @param pakg mapped java package.
* @param pakg mapped java package
*/
@Override
public void setPackage(String pakg) {
......@@ -341,7 +341,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the file handle of the cached file used during code generation.
*
* @return cached file handle.
* @return cached file handle
*/
@Override
public CachedFileHandle getFileHandle() {
......@@ -352,7 +352,7 @@ public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the file handle to be used used for code generation.
*
* @param fileHandle cached file handle.
* @param fileHandle cached file handle
*/
@Override
public void setFileHandle(CachedFileHandle fileHandle) {
......
......@@ -17,7 +17,7 @@ package org.onosproject.yangutils.datamodel;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
import org.onosproject.yangutils.utils.YangConstructType;
import org.onosproject.yangutils.translator.CachedFileHandle;
/*-
......@@ -90,7 +90,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the name.
*
* @return the name.
* @return the name
*/
public String getRefGroupingName() {
return name;
......@@ -108,7 +108,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the referred group.
*
* @return the referred group.
* @return the referred group
*/
public YangGrouping getRefGroup() {
return refGroup;
......@@ -117,7 +117,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the referred group.
*
* @param refGroup the referred group.
* @param refGroup the referred group
*/
public void setRefGroup(YangGrouping refGroup) {
this.refGroup = refGroup;
......@@ -126,7 +126,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the description.
*
* @return the description.
* @return the description
*/
@Override
public String getDescription() {
......@@ -136,7 +136,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the description.
*
* @param description set the description.
* @param description set the description
*/
@Override
public void setDescription(String description) {
......@@ -146,7 +146,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the textual reference.
*
* @return the reference.
* @return the reference
*/
@Override
public String getReference() {
......@@ -156,7 +156,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the textual reference.
*
* @param reference the reference to set.
* @param reference the reference to set
*/
@Override
public void setReference(String reference) {
......@@ -166,7 +166,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Get the status.
*
* @return the status.
* @return the status
*/
@Override
public YangStatusType getStatus() {
......@@ -176,7 +176,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Set the status.
*
* @param status the status to set.
* @param status the status to set
*/
@Override
public void setStatus(YangStatusType status) {
......@@ -186,17 +186,17 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Returns the type of the data.
*
* @return returns USES_DATA.
* @return returns USES_DATA
*/
@Override
public ParsableDataType getParsableDataType() {
return ParsableDataType.USES_DATA;
public YangConstructType getYangConstructType() {
return YangConstructType.USES_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnEntry() throws DataModelException {
......@@ -206,7 +206,7 @@ public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
* @throws DataModelException a violation of data model rules
*/
@Override
public void validateDataOnExit() throws DataModelException {
......
/*
* 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.datamodel.utils;
import org.onosproject.yangutils.datamodel.CollisionDetector;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangLeavesHolder;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.utils.YangConstructType;
/**
* Utilities for data model tree.
*/
public final class DataModelUtils {
/**
* Creates a new data model tree utility.
*/
private DataModelUtils() {
}
/**
* Detects the colliding identifier name in a given YANG node and its child.
*
* @param identifierName name for which collision detection is to be
* checked.
* @param dataType type of YANG node asking for detecting collision.
* @param node instance of calling node.
* @throws DataModelException a violation of data model rules.
*/
public static void detectCollidingChildUtil(String identifierName, YangConstructType dataType, YangNode node)
throws DataModelException {
if (((YangLeavesHolder) node).getListOfLeaf() != null) {
for (YangLeaf leaf : ((YangLeavesHolder) node).getListOfLeaf()) {
if (leaf.getLeafName().equals(identifierName)) {
throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf \""
+ leaf.getLeafName() + "\"");
}
}
}
if (((YangLeavesHolder) node).getListOfLeafList() != null) {
for (YangLeafList leafList : ((YangLeavesHolder) node).getListOfLeafList()) {
if (leafList.getLeafName().equals(identifierName)) {
throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf " +
"list \"" + leafList.getLeafName() + "\"");
}
}
}
node = node.getChild();
while ((node != null)) {
if (node instanceof CollisionDetector) {
((CollisionDetector) node).detectSelfCollision(identifierName, dataType);
}
node = node.getNextSibling();
}
}
}
/*
* 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.
*/
/**
* Utilities for checking data model tree collisions.
*/
package org.onosproject.yangutils.datamodel.utils;
\ No newline at end of file
......@@ -17,6 +17,7 @@
package org.onosproject.yangutils.parser;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.utils.YangConstructType;
/**
* Abstraction of an entity which process the data of lexer's parse tree.
......@@ -24,11 +25,11 @@ import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
public interface Parsable {
/**
* Get the type of parsable data.
* Get the type of YANG construct data.
*
* @return the type of parsable data
* @return the type of YANG construct data.
*/
ParsableDataType getParsableDataType();
YangConstructType getYangConstructType();
/**
* Check if the node is valid as per YANG grammar's syntax and semantics.
......
......@@ -29,10 +29,10 @@ public interface YangUtilsParser {
/**
* It is an entry function to initiate the YANG file parsing.
*
* @param file input YANG file.
* @return YangNode root node of the data model tree.
* @throws ParserException when fails to get the data model.
* @throws IOException when there is an exception in IO operation.
* @param file input YANG file
* @return YangNode root node of the data model tree
* @throws ParserException when fails to get the data model
* @throws IOException when there is an exception in IO operation
*/
YangNode getDataModel(String file) throws IOException, ParserException;
}
......
......@@ -88,7 +88,7 @@ public class TreeWalkListener implements GeneratedYangListener {
/**
* Returns root node.
*
* @return rootNode of data model tree.
* @return rootNode of data model tree
*/
public YangNode getRootNode() {
return rootNode;
......@@ -97,7 +97,7 @@ public class TreeWalkListener implements GeneratedYangListener {
/**
* Set parsed data stack.
*
* @param parsedDataStack stack of parsable data objects.
* @param parsedDataStack stack of parsable data objects
*/
public void setParsedDataStack(Stack<Parsable> parsedDataStack) {
this.parsedDataStack = parsedDataStack;
......@@ -106,7 +106,7 @@ public class TreeWalkListener implements GeneratedYangListener {
/**
* Set root node.
*
* @param rootNode root node of data model tree.
* @param rootNode root node of data model tree
*/
public void setRootNode(YangNode rootNode) {
this.rootNode = rootNode;
......
......@@ -22,14 +22,15 @@ import org.onosproject.yangutils.datamodel.YangSubModule;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.YANGBASE_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.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CHILD;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.utils.YangConstructType.YANGBASE_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -55,8 +56,8 @@ public final class BaseFileListener {
* It is called when parser receives an input matching the grammar rule
* (yangfile), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processYangFileEntry(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) {
......@@ -69,8 +70,8 @@ public final class BaseFileListener {
* It is called when parser exits from grammar rule (yangfile), it perform
* validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processYangFileExit(TreeWalkListener listener, GeneratedYangParser.YangfileContext ctx) {
......
......@@ -22,13 +22,14 @@ import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.BELONGS_TO_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.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.utils.YangConstructType.BELONGS_TO_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -70,8 +71,8 @@ public final class BelongsToListener {
* It is called when parser receives an input matching the grammar rule
* (belongsto), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processBelongsToEntry(TreeWalkListener listener,
GeneratedYangParser.BelongstoStatementContext ctx) {
......@@ -91,8 +92,8 @@ public final class BelongsToListener {
* It is called when parser exits from grammar rule (belongsto), it perform
* validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processBelongsToExit(TreeWalkListener listener,
GeneratedYangParser.BelongstoStatementContext ctx) {
......@@ -110,7 +111,7 @@ public final class BelongsToListener {
ctx.IDENTIFIER().getText(), EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
switch (tmpNode.getYangConstructType()) {
case SUB_MODULE_DATA: {
YangSubModule subModule = (YangSubModule) tmpNode;
subModule.setBelongsTo((YangBelongsTo) tmpBelongstoNode);
......
......@@ -65,7 +65,7 @@ import org.onosproject.yangutils.datamodel.YangBit;
import org.onosproject.yangutils.datamodel.YangBits;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import static org.onosproject.yangutils.parser.ParsableDataType.BIT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.BIT_DATA;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
......@@ -95,8 +95,8 @@ public final class BitListener {
* It is called when parser enters grammar rule (bit), it perform
* validations and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processBitEntry(TreeWalkListener listener,
GeneratedYangParser.BitStatementContext ctx) {
......@@ -113,8 +113,8 @@ public final class BitListener {
* It is called when parser exits from grammar rule (bit), it perform
* validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processBitExit(TreeWalkListener listener,
GeneratedYangParser.BitStatementContext ctx) {
......@@ -130,7 +130,7 @@ public final class BitListener {
checkStackIsNotEmpty(listener, MISSING_HOLDER, BIT_DATA, ctx.IDENTIFIER().getText(), EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
switch (tmpNode.getYangConstructType()) {
case BITS_DATA: {
YangBits yangBits = (YangBits) tmpNode;
if ((ctx.bitBodyStatement() == null) || (ctx.bitBodyStatement().positionStatement() == null)) {
......
......@@ -46,8 +46,8 @@ import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.parser.Parsable;
import static org.onosproject.yangutils.parser.ParsableDataType.BITS_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.BITS_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
......@@ -75,8 +75,8 @@ public final class BitsListener {
* It is called when parser enters grammar rule (bits), it perform
* validations and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processBitsEntry(TreeWalkListener listener,
GeneratedYangParser.BitsSpecificationContext ctx) {
......@@ -93,7 +93,7 @@ public final class BitsListener {
Parsable tmpData = listener.getParsedDataStack().peek();
switch (tmpData.getParsableDataType()) {
switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
bitsNode.setBitsName(((YangLeaf) tmpData).getLeafName());
break;
......@@ -116,8 +116,8 @@ public final class BitsListener {
* It is called when parser exits from grammar rule (bits), it perform
* validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processBitsExit(TreeWalkListener listener,
GeneratedYangParser.BitsSpecificationContext ctx) {
......@@ -133,7 +133,7 @@ public final class BitsListener {
checkStackIsNotEmpty(listener, MISSING_HOLDER, BITS_DATA, "", EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
switch (tmpNode.getYangConstructType()) {
case TYPE_DATA: {
YangType typeNode = (YangType) tmpNode;
typeNode.setDataTypeExtendedInfo((YangBits) tmpBitsNode);
......
......@@ -24,13 +24,12 @@ import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.CONFIG_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -62,8 +61,8 @@ 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.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processConfigEntry(TreeWalkListener listener,
GeneratedYangParser.ConfigStatementContext ctx) {
......@@ -77,7 +76,7 @@ public final class ConfigListener {
}
Parsable tmpData = listener.getParsedDataStack().peek();
switch (tmpData.getParsableDataType()) {
switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
YangLeaf leaf = (YangLeaf) tmpData;
leaf.setConfig(isConfig);
......
......@@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.CONTACT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.CONTACT_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
......@@ -86,8 +86,8 @@ public final class ContactListener {
* It is called when parser receives an input matching the grammar rule
* (contact), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processContactEntry(TreeWalkListener listener, GeneratedYangParser.ContactStatementContext ctx) {
......@@ -96,7 +96,7 @@ public final class ContactListener {
// Obtain the node of the stack.
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
module.setContact(ctx.string().getText());
......
......@@ -22,24 +22,27 @@ import org.onosproject.yangutils.datamodel.YangModule;
import org.onosproject.yangutils.datamodel.YangNode;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
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 org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.CONTAINER_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.CONTAINER_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.PRESENCE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -76,8 +79,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati
*/
public final class ContainerListener {
private static ParsableDataType yangConstruct;
/**
* Creates a new container listener.
*/
......@@ -85,30 +86,34 @@ public final class ContainerListener {
}
/**
* It is called when parser receives an input matching the grammar
* rule (container), performs validation and updates the data model
* tree.
* It is called when parser receives an input matching the grammar rule
* (container), performs validation and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processContainerEntry(TreeWalkListener listener,
GeneratedYangParser.ContainerStatementContext ctx) {
YangNode parentNode;
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, CONTAINER_DATA, ctx.IDENTIFIER().getText(), ENTRY);
boolean result = validateSubStatementsCardinality(ctx);
if (!result) {
throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
}
// Validate sub statement cardinality.
validateSubStatementsCardinality(ctx);
// Check for identifier collision
int line = ctx.IDENTIFIER().getSymbol().getLine();
int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine();
String identifierName = ctx.IDENTIFIER().getText();
detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, CONTAINER_DATA);
YangContainer container = new YangContainer();
container.setName(ctx.IDENTIFIER().getText());
/* If "config" is not specified, the default is the same as the parent
schema node's "config" value. */
/*
* If "config" is not specified, the default is the same as the parent
* schema node's "config" value.
*/
if (ctx.configStatement().isEmpty()) {
boolean parentConfig = ListenerValidation.getParentNodeConfig(listener);
container.setConfig(parentConfig);
......@@ -135,8 +140,8 @@ public final class ContainerListener {
* It is called when parser exits from grammar rule (container), it perform
* validations and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processContainerExit(TreeWalkListener listener,
GeneratedYangParser.ContainerStatementContext ctx) {
......@@ -162,41 +167,15 @@ public final class ContainerListener {
/**
* Validates the cardinality of container sub-statements as per grammar.
*
* @param ctx context object of the grammar rule.
* @return true/false validation success or failure.
* @param ctx context object of the grammar rule
*/
private static boolean validateSubStatementsCardinality(GeneratedYangParser.ContainerStatementContext ctx) {
if ((!ctx.presenceStatement().isEmpty())
&& (ctx.presenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.PRESENCE_DATA;
return false;
}
if ((!ctx.configStatement().isEmpty())
&& (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.CONFIG_DATA;
return false;
}
if ((!ctx.descriptionStatement().isEmpty())
&& (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.DESCRIPTION_DATA;
return false;
}
if ((!ctx.referenceStatement().isEmpty())
&& (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.REFERENCE_DATA;
return false;
}
if ((!ctx.statusStatement().isEmpty())
&& (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.STATUS_DATA;
return false;
}
return true;
private static void validateSubStatementsCardinality(GeneratedYangParser.ContainerStatementContext ctx) {
validateCardinality(ctx.presenceStatement(), PRESENCE_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.configStatement(), CONFIG_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.statusStatement(), STATUS_DATA, CONTAINER_DATA, ctx.IDENTIFIER().getText());
// TODO when, grouping, typedef.
}
}
......
......@@ -45,7 +45,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.DEFAULT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DEFAULT_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
......@@ -64,8 +64,8 @@ public final class DefaultListener {
* It is called when parser enters grammar rule (default), it perform
* validations and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processDefaultEntry(TreeWalkListener listener,
GeneratedYangParser.DefaultStatementContext ctx) {
......@@ -74,7 +74,7 @@ public final class DefaultListener {
checkStackIsNotEmpty(listener, MISSING_HOLDER, DEFAULT_DATA, ctx.string().getText(), ENTRY);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
switch (tmpNode.getYangConstructType()) {
case TYPEDEF_DATA: {
YangTypeDef typeDef = (YangTypeDef) tmpNode;
typeDef.setDefaultValueInString(ctx.string().getText());
......
......@@ -22,7 +22,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
......@@ -56,8 +56,8 @@ public final class DescriptionListener {
* rule (description), perform validations and updates the data model
* tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processDescriptionEntry(TreeWalkListener listener,
GeneratedYangParser.DescriptionStatementContext ctx) {
......
......@@ -64,7 +64,7 @@ import org.onosproject.yangutils.datamodel.YangEnum;
import org.onosproject.yangutils.datamodel.YangEnumeration;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import static org.onosproject.yangutils.parser.ParsableDataType.ENUM_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.ENUM_DATA;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
......@@ -94,8 +94,8 @@ public final class EnumListener {
* It is called when parser enters grammar rule (enum), it perform
* validations and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processEnumEntry(TreeWalkListener listener, GeneratedYangParser.EnumStatementContext ctx) {
......@@ -111,8 +111,8 @@ public final class EnumListener {
* It is called when parser exits from grammar rule (enum), it perform
* validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processEnumExit(TreeWalkListener listener, GeneratedYangParser.EnumStatementContext ctx) {
......@@ -127,7 +127,7 @@ public final class EnumListener {
checkStackIsNotEmpty(listener, MISSING_HOLDER, ENUM_DATA, ctx.string().getText(), EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
switch (tmpNode.getYangConstructType()) {
case ENUMERATION_DATA: {
YangEnumeration yangEnumeration = (YangEnumeration) tmpNode;
if ((ctx.enumStatementBody() == null) || (ctx.enumStatementBody().valueStatement() == null)) {
......
......@@ -46,8 +46,8 @@ import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangType;
import org.onosproject.yangutils.parser.Parsable;
import static org.onosproject.yangutils.parser.ParsableDataType.ENUMERATION_DATA;
import static org.onosproject.yangutils.parser.ParsableDataType.TYPE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.ENUMERATION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
......@@ -76,8 +76,8 @@ public final class EnumerationListener {
* It is called when parser enters grammar rule (enumeration), it perform
* validations and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processEnumerationEntry(TreeWalkListener listener,
GeneratedYangParser.EnumSpecificationContext ctx) {
......@@ -94,7 +94,7 @@ public final class EnumerationListener {
Parsable tmpData = listener.getParsedDataStack().peek();
switch (tmpData.getParsableDataType()) {
switch (tmpData.getYangConstructType()) {
case LEAF_DATA:
enumerationNode.setEnumerationName(((YangLeaf) tmpData).getLeafName());
break;
......@@ -117,8 +117,8 @@ public final class EnumerationListener {
* It is called when parser exits from grammar rule (enumeration), it
* perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processEnumerationExit(TreeWalkListener listener,
GeneratedYangParser.EnumSpecificationContext ctx) {
......@@ -134,7 +134,7 @@ public final class EnumerationListener {
checkStackIsNotEmpty(listener, MISSING_HOLDER, ENUMERATION_DATA, "", EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
switch (tmpNode.getYangConstructType()) {
case TYPE_DATA: {
YangType typeNode = (YangType) tmpNode;
typeNode.setDataTypeExtendedInfo((YangEnumeration) tmpEnumerationNode);
......
......@@ -23,13 +23,14 @@ import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.IMPORT_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.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.utils.YangConstructType.IMPORT_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -69,8 +70,8 @@ public final class ImportListener {
* It is called when parser receives an input matching the grammar rule
* (import), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processImportEntry(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) {
......@@ -88,8 +89,8 @@ public final class ImportListener {
* It is called when parser exits from grammar rule (import), it perform
* validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processImportExit(TreeWalkListener listener, GeneratedYangParser.ImportStatementContext ctx) {
......@@ -105,7 +106,7 @@ public final class ImportListener {
EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
module.addImportedInfo((YangImport) tmpImportNode);
......
......@@ -23,13 +23,14 @@ import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.INCLUDE_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.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.utils.YangConstructType.INCLUDE_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -68,8 +69,8 @@ public final class IncludeListener {
* It is called when parser receives an input matching the grammar rule
* (include), perform validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processIncludeEntry(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) {
......@@ -87,8 +88,8 @@ public final class IncludeListener {
* It is called when parser exits from grammar rule (include), it perform
* validations and update the data model tree.
*
* @param listener Listener's object.
* @param ctx context object of the grammar rule.
* @param listener Listener's object
* @param ctx context object of the grammar rule
*/
public static void processIncludeExit(TreeWalkListener listener, GeneratedYangParser.IncludeStatementContext ctx) {
......@@ -104,7 +105,7 @@ public final class IncludeListener {
EXIT);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
switch (tmpNode.getYangConstructType()) {
case MODULE_DATA: {
YangModule module = (YangModule) tmpNode;
module.addIncludedInfo((YangInclude) tmpIncludeNode);
......
......@@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.KEY_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.KEY_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
......@@ -59,8 +59,8 @@ public final class KeyListener {
* rule (key), perform validations and updates the data model
* tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processKeyEntry(TreeWalkListener listener,
GeneratedYangParser.KeyStatementContext ctx) {
......
......@@ -19,21 +19,28 @@ package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangLeafList;
import org.onosproject.yangutils.datamodel.YangLeavesHolder;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
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.LEAF_LIST_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
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.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEqualsOne;
import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.LEAF_LIST_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.MAX_ELEMENT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.MIN_ELEMENT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.UNITS_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -68,8 +75,6 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati
*/
public final class LeafListListener {
private static ParsableDataType yangConstruct;
/**
* Creates a new leaf list listener.
*/
......@@ -77,12 +82,11 @@ public final class LeafListListener {
}
/**
* It is called when parser receives an input matching the grammar
* rule (leaf-list), performs validation and updates the data model
* tree.
* It is called when parser receives an input matching the grammar rule
* (leaf-list), performs validation and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processLeafListEntry(TreeWalkListener listener,
GeneratedYangParser.LeafListStatementContext ctx) {
......@@ -90,10 +94,14 @@ public final class LeafListListener {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY);
boolean result = validateSubStatementsCardinality(ctx);
if (!result) {
throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
}
// Validate sub statement cardinality.
validateSubStatementsCardinality(ctx);
// Check for identifier collision
int line = ctx.IDENTIFIER().getSymbol().getLine();
int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine();
String identifierName = ctx.IDENTIFIER().getText();
detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, LEAF_LIST_DATA);
YangLeafList leafList = new YangLeafList();
leafList.setLeafName(ctx.IDENTIFIER().getText());
......@@ -115,8 +123,8 @@ public final class LeafListListener {
* It is called when parser exits from grammar rule (leaf-list), it performs
* validation and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processLeafListExit(TreeWalkListener listener,
GeneratedYangParser.LeafListStatementContext ctx) {
......@@ -136,59 +144,17 @@ public final class LeafListListener {
* Validates the cardinality of leaf-list sub-statements as per grammar.
*
* @param ctx context object of the grammar rule.
* @return true/false validation success or failure.
*/
private static boolean validateSubStatementsCardinality(GeneratedYangParser
.LeafListStatementContext ctx) {
if (ctx.typeStatement().isEmpty()
|| (ctx.typeStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.TYPE_DATA;
return false;
}
if ((!ctx.unitsStatement().isEmpty())
&& (ctx.unitsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.UNITS_DATA;
return false;
}
if ((!ctx.configStatement().isEmpty())
&& (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.CONFIG_DATA;
return false;
}
if ((!ctx.maxElementsStatement().isEmpty())
&& (ctx.maxElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.MAX_ELEMENT_DATA;
return false;
}
if ((!ctx.minElementsStatement().isEmpty())
&& (ctx.minElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.MIN_ELEMENT_DATA;
return false;
}
if ((!ctx.descriptionStatement().isEmpty())
&& (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.DESCRIPTION_DATA;
return false;
}
if ((!ctx.referenceStatement().isEmpty())
&& (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.REFERENCE_DATA;
return false;
}
if ((!ctx.statusStatement().isEmpty())
&& (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.STATUS_DATA;
return false;
}
return true;
private static void validateSubStatementsCardinality(GeneratedYangParser.LeafListStatementContext ctx) {
validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.unitsStatement(), UNITS_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.configStatement(), CONFIG_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.maxElementsStatement(), MAX_ELEMENT_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.minElementsStatement(), MIN_ELEMENT_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.statusStatement(), STATUS_DATA, LEAF_LIST_DATA, ctx.IDENTIFIER().getText());
//TODO ordered by
}
}
......
......@@ -21,23 +21,29 @@
package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangLeaf;
import org.onosproject.yangutils.datamodel.YangLeavesHolder;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
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.datamodel.YangLeavesHolder;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import static org.onosproject.yangutils.parser.ParsableDataType.LEAF_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
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.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityEqualsOne;
import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.LEAF_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.MANDATORY_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.UNITS_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -66,13 +72,11 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati
*/
/**
* Implements listener based call back function corresponding to the "leaf"
* rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
* Implements listener based call back function corresponding to the "leaf" rule
* defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
*/
public final class LeafListener {
private static ParsableDataType yangConstruct;
/**
* Creates a new leaf listener.
*/
......@@ -80,12 +84,11 @@ public final class LeafListener {
}
/**
* It is called when parser receives an input matching the grammar
* rule (leaf), performs validation and updates the data model
* tree.
* It is called when parser receives an input matching the grammar rule
* (leaf), performs validation and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processLeafEntry(TreeWalkListener listener,
GeneratedYangParser.LeafStatementContext ctx) {
......@@ -93,10 +96,14 @@ public final class LeafListener {
// Check for stack to be non empty.
checkStackIsNotEmpty(listener, MISSING_HOLDER, LEAF_DATA, ctx.IDENTIFIER().getText(), ENTRY);
boolean result = validateSubStatementsCardinality(ctx);
if (!result) {
throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
}
// Validate sub statement cardinality.
validateSubStatementsCardinality(ctx);
// Check for identifier collision
int line = ctx.IDENTIFIER().getSymbol().getLine();
int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine();
String identifierName = ctx.IDENTIFIER().getText();
detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, LEAF_DATA);
YangLeaf leaf = new YangLeaf();
leaf.setLeafName(ctx.IDENTIFIER().getText());
......@@ -140,53 +147,16 @@ public final class LeafListener {
* Validates the cardinality of leaf sub-statements as per grammar.
*
* @param ctx context object of the grammar rule.
* @return true/false validation success or failure.
*/
private static boolean validateSubStatementsCardinality(GeneratedYangParser
.LeafStatementContext ctx) {
if (ctx.typeStatement().isEmpty()
|| (ctx.typeStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.TYPE_DATA;
return false;
}
if ((!ctx.unitsStatement().isEmpty())
&& (ctx.unitsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.UNITS_DATA;
return false;
}
if ((!ctx.configStatement().isEmpty())
&& (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.CONFIG_DATA;
return false;
}
if ((!ctx.mandatoryStatement().isEmpty())
&& (ctx.mandatoryStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.MANDATORY_DATA;
return false;
}
if ((!ctx.descriptionStatement().isEmpty())
&& (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.DESCRIPTION_DATA;
return false;
}
if ((!ctx.referenceStatement().isEmpty())
&& (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.REFERENCE_DATA;
return false;
}
if ((!ctx.statusStatement().isEmpty())
&& (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.STATUS_DATA;
return false;
}
return true;
private static void validateSubStatementsCardinality(GeneratedYangParser.LeafStatementContext ctx) {
validateCardinalityEqualsOne(ctx.typeStatement(), TYPE_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.unitsStatement(), UNITS_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.configStatement(), CONFIG_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.mandatoryStatement(), MANDATORY_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.statusStatement(), STATUS_DATA, LEAF_DATA, ctx.IDENTIFIER().getText());
//TODO when.
}
}
......
......@@ -16,31 +16,38 @@
package org.onosproject.yangutils.parser.impl.listeners;
import org.onosproject.yangutils.datamodel.YangList;
import org.onosproject.yangutils.datamodel.YangContainer;
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.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
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 org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.ParsableDataType.LIST_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerCollisionDetector.detectCollidingChildUtil;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_CARDINALITY;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinality;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityNonNull;
import static org.onosproject.yangutils.utils.YangConstructType.CONFIG_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DATA_DEF_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.DESCRIPTION_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.KEY_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.LIST_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.MAX_ELEMENT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.MIN_ELEMENT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.REFERENCE_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.STATUS_DATA;
/*
* Reference: RFC6020 and YANG ANTLR Grammar
......@@ -74,13 +81,11 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidati
*/
/**
* Implements listener based call back function corresponding to the "list"
* rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
* Implements listener based call back function corresponding to the "list" rule
* defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
*/
public final class ListListener {
private static ParsableDataType yangConstruct;
/**
* Creates a new list listener.
*/
......@@ -88,12 +93,11 @@ public final class ListListener {
}
/**
* It is called when parser receives an input matching the grammar
* rule (list), performs validation and updates the data model
* tree.
* It is called when parser receives an input matching the grammar rule
* (list), performs validation and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processListEntry(TreeWalkListener listener,
GeneratedYangParser.ListStatementContext ctx) {
......@@ -102,16 +106,22 @@ public final class ListListener {
checkStackIsNotEmpty(listener, MISSING_HOLDER, LIST_DATA, ctx.IDENTIFIER().getText(), ENTRY);
boolean result = validateSubStatementsCardinality(ctx);
if (!result) {
throw new ParserException(constructListenerErrorMessage(INVALID_CARDINALITY, yangConstruct, "", ENTRY));
}
// Validate sub statement cardinality.
validateSubStatementsCardinality(ctx);
// Check for identifier collision
int line = ctx.IDENTIFIER().getSymbol().getLine();
int charPositionInLine = ctx.IDENTIFIER().getSymbol().getCharPositionInLine();
String identifierName = ctx.IDENTIFIER().getText();
detectCollidingChildUtil(listener, line, charPositionInLine, identifierName, LIST_DATA);
YangList yangList = new YangList(YangNodeType.LIST_NODE);
yangList.setName(ctx.IDENTIFIER().getText());
/* If "config" is not specified, the default is the same as the parent
schema node's "config" value. */
/*
* If "config" is not specified, the default is the same as the parent
* schema node's "config" value.
*/
if (ctx.configStatement().isEmpty()) {
boolean parentConfig = ListenerValidation.getParentNodeConfig(listener);
yangList.setConfig(parentConfig);
......@@ -138,8 +148,8 @@ public final class ListListener {
* It is called when parser exits from grammar rule (list), it performs
* validation and updates the data model tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processListExit(TreeWalkListener listener,
GeneratedYangParser.ListStatementContext ctx) {
......@@ -164,58 +174,18 @@ public final class ListListener {
/**
* Validates the cardinality of list sub-statements as per grammar.
*
* @param ctx context object of the grammar rule.
* @return true/false validation success or failure.
* @param ctx context object of the grammar rule
*/
private static boolean validateSubStatementsCardinality(GeneratedYangParser.ListStatementContext ctx) {
if ((!ctx.keyStatement().isEmpty())
&& (ctx.keyStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.KEY_DATA;
return false;
}
if ((!ctx.configStatement().isEmpty())
&& (ctx.configStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.CONFIG_DATA;
return false;
}
if ((!ctx.maxElementsStatement().isEmpty())
&& (ctx.maxElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.MAX_ELEMENT_DATA;
return false;
}
if ((!ctx.minElementsStatement().isEmpty())
&& (ctx.minElementsStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.MIN_ELEMENT_DATA;
return false;
}
if ((!ctx.descriptionStatement().isEmpty())
&& (ctx.descriptionStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.DESCRIPTION_DATA;
return false;
}
if ((!ctx.referenceStatement().isEmpty())
&& (ctx.referenceStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.REFERENCE_DATA;
return false;
}
if ((!ctx.statusStatement().isEmpty())
&& (ctx.statusStatement().size() != YangUtilsParserManager.SUB_STATEMENT_CARDINALITY)) {
yangConstruct = ParsableDataType.STATUS_DATA;
return false;
}
if (ctx.dataDefStatement().isEmpty()) {
yangConstruct = ParsableDataType.LIST_DATA;
return false;
}
return true;
private static void validateSubStatementsCardinality(GeneratedYangParser.ListStatementContext ctx) {
validateCardinality(ctx.keyStatement(), KEY_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.configStatement(), CONFIG_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.maxElementsStatement(), MAX_ELEMENT_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.minElementsStatement(), MIN_ELEMENT_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.descriptionStatement(), DESCRIPTION_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.referenceStatement(), REFERENCE_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinality(ctx.statusStatement(), STATUS_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
validateCardinalityNonNull(ctx.dataDefStatement(), DATA_DEF_DATA, LIST_DATA, ctx.IDENTIFIER().getText());
//TODO when, typedef, grouping, unique
}
}
......
......@@ -22,7 +22,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.MANDATORY_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.MANDATORY_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
......@@ -62,8 +62,8 @@ public final class MandatoryListener {
* rule (mandatory), performs validation and updates the data model
* tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processMandatoryEntry(TreeWalkListener listener,
GeneratedYangParser.MandatoryStatementContext ctx) {
......@@ -72,7 +72,7 @@ public final class MandatoryListener {
checkStackIsNotEmpty(listener, MISSING_HOLDER, MANDATORY_DATA, "", ENTRY);
Parsable tmpNode = listener.getParsedDataStack().peek();
switch (tmpNode.getParsableDataType()) {
switch (tmpNode.getYangConstructType()) {
case LEAF_DATA:
YangLeaf leaf = (YangLeaf) tmpNode;
if (ctx.TRUE_KEYWORD() != null) {
......
......@@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.MAX_ELEMENT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.MAX_ELEMENT_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
......@@ -60,8 +60,8 @@ public final class MaxElementsListener {
* rule (max-elements), performs validation and updates the data model
* tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processMaxElementsEntry(TreeWalkListener listener,
GeneratedYangParser.MaxElementsStatementContext ctx) {
......@@ -77,7 +77,7 @@ public final class MaxElementsListener {
}
Parsable tmpData = listener.getParsedDataStack().peek();
switch (tmpData.getParsableDataType()) {
switch (tmpData.getYangConstructType()) {
case LEAF_LIST_DATA:
YangLeafList leafList = (YangLeafList) tmpData;
leafList.setMaxElelements(maxElementsValue);
......
......@@ -23,7 +23,7 @@ import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
import static org.onosproject.yangutils.parser.ParsableDataType.MIN_ELEMENT_DATA;
import static org.onosproject.yangutils.utils.YangConstructType.MIN_ELEMENT_DATA;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
......@@ -61,8 +61,8 @@ public final class MinElementsListener {
* rule (min-elements), performs validation and updates the data model
* tree.
*
* @param listener listener's object.
* @param ctx context object of the grammar rule.
* @param listener listener's object
* @param ctx context object of the grammar rule
*/
public static void processMinElementsEntry(TreeWalkListener listener,
GeneratedYangParser.MinElementsStatementContext ctx) {
......@@ -71,7 +71,7 @@ public final class MinElementsListener {
checkStackIsNotEmpty(listener, MISSING_HOLDER, MIN_ELEMENT_DATA, ctx.INTEGER().getText(), ENTRY);
Parsable tmpData = listener.getParsedDataStack().peek();
switch (tmpData.getParsableDataType()) {
switch (tmpData.getYangConstructType()) {
case LEAF_LIST_DATA:
YangLeafList leafList = (YangLeafList) tmpData;
leafList.setMinElements(Integer.parseInt(ctx.INTEGER().getText()));
......
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.