Vinod Kumar S
Committed by Gerrit Code Review

[ONOS-3905, ONOS-3901, ONOS-3900] choice, grouping and augment data model support.

Change-Id: Iaee5175e4e06249f5b56192f4744e9297289194c
/*
* 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 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;
/*-
* Reference RFC 6020.
*
* The "augment" statement allows a module or submodule to add to the
* schema tree defined in an external module, or the current module and
* its submodules, and to add to the nodes from a grouping in a "uses"
* statement. The argument is a string that identifies a node in the
* schema tree. This node is called the augment's target node. The
* target node MUST be either a container, list, choice, case, input,
* output, or notification node. It is augmented with the nodes defined
* in the sub-statements that follow the "augment" statement.
*
* The argument string is a schema node identifier.
* If the "augment" statement is on the top level in a module or
* submodule, the absolute form of a schema node identifier
* MUST be used. If the "augment" statement is a sub-statement to the
* "uses" statement, the descendant form MUST be used.
*
* If the target node is a container, list, case, input, output, or
* notification node, the "container", "leaf", "list", "leaf-list",
* "uses", and "choice" statements can be used within the "augment"
* statement.
*
* If the target node is a choice node, the "case" statement, or a case
* shorthand statement can be used within the "augment" statement.
*
* If the target node is in another module, then nodes added by the
* augmentation MUST NOT be mandatory nodes.
*
* The "augment" statement MUST NOT add multiple nodes with the same
* name from the same module to the target node.
* The augment's sub-statements
*
* +--------------+---------+-------------+------------------+
* | substatement | section | cardinality |data model mapping|
* +--------------+---------+-------------+------------------+
* | anyxml | 7.10 | 0..n |-not supported |
* | case | 7.9.2 | 0..n |-child nodes |
* | choice | 7.9 | 0..n |-child nodes |
* | container | 7.5 | 0..n |-child nodes |
* | description | 7.19.3 | 0..1 |-string |
* | if-feature | 7.18.2 | 0..n |-TODO |
* | leaf | 7.6 | 0..n |-YangLeaf |
* | leaf-list | 7.7 | 0..n |-YangLeafList |
* | list | 7.8 | 0..n |-child nodes |
* | reference | 7.19.4 | 0..1 |-String |
* | status | 7.19.2 | 0..1 |-YangStatus |
* | uses | 7.12 | 0..n |-child nodes |
* | when | 7.19.5 | 0..1 |-TODO |
* +--------------+---------+-------------+------------------+
*/
/**
* Data model node to maintain information defined in YANG augment.
*/
public class YangAugment extends YangNode
implements YangLeavesHolder, YangCommonInfo, Parsable {
/**
* Augment target node.
*/
private String targetNode;
/**
* description of augment.
*/
private String description;
/**
* List of leaves.
*/
@SuppressWarnings("rawtypes")
private List<YangLeaf> listOfLeaf;
/**
* List of leaf-lists.
*/
@SuppressWarnings("rawtypes")
private List<YangLeafList> listOfLeafList;
/**
* reference.
*/
private String reference;
/**
* Status of the node.
*/
private YangStatusType status;
/**
* Create a YANG augment node.
*/
public YangAugment() {
super(YangNodeType.AUGMENT_NODE);
}
/**
* Get the augmented node.
*
* @return the augmented node.
*/
public String getTargetNode() {
return targetNode;
}
/**
* Set the augmented node.
*
* @param targetNode the augmented node.
*/
public void setTargetNode(String targetNode) {
this.targetNode = targetNode;
}
/**
* Get the description.
*
* @return the description.
*/
public String getDescription() {
return description;
}
/**
* Set the description.
*
* @param description set the description.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Get the list of leaves.
*
* @return the list of leaves.
*/
@SuppressWarnings("rawtypes")
public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
/**
* Set the list of leaves.
*
* @param leafsList the list of leaf to set.
*/
@SuppressWarnings("rawtypes")
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
/**
* Add a leaf.
*
* @param leaf the leaf to be added.
*/
@SuppressWarnings("rawtypes")
public void addLeaf(YangLeaf<?> leaf) {
if (getListOfLeaf() == null) {
setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
}
/**
* Get the list of leaf-list.
*
* @return the list of leaf-list.
*/
@SuppressWarnings("rawtypes")
public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
/**
* Set the list of leaf-list.
*
* @param listOfLeafList the list of leaf-list to set.
*/
@SuppressWarnings("rawtypes")
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
/**
* Add a leaf-list.
*
* @param leafList the leaf-list to be added.
*/
@SuppressWarnings("rawtypes")
public void addLeafList(YangLeafList<?> leafList) {
if (getListOfLeafList() == null) {
setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
}
/**
* Get the textual reference.
*
* @return the reference.
*/
public String getReference() {
return reference;
}
/**
* Set the textual reference.
*
* @param reference the reference to set.
*/
public void setReference(String reference) {
this.reference = reference;
}
/**
* Get the status.
*
* @return the status.
*/
public YangStatusType getStatus() {
return status;
}
/**
* Set the status.
*
* @param status the status to set.
*/
public void setStatus(YangStatusType status) {
this.status = status;
}
/**
* Returns the type of the data as belongs-to.
*
* @return returns AUGMENT_DATA.
*/
public ParsableDataType getParsableDataType() {
return ParsableDataType.AUGMENT_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
*/
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
*/
@Override
public void setName(String name) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
*/
public void generateJavaCodeEntry() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
*/
public void generateJavaCodeExit() {
// TODO Auto-generated method stub
}
}
/*
* 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.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
/*-
* The "bit" statement, which is a sub-statement to the "type" statement,
* MUST be present if the type is "bits". It is repeatedly used to
* specify each assigned named bit of a bits type. It takes as an
* argument a string that is the assigned name of the bit. It is
* followed by a block of sub-statements that holds detailed bit
* information.
* All assigned names in a bits type MUST be unique.
*
* The bit's sub-statements
*
* +--------------+---------+-------------+------------------+
* | substatement | section | cardinality |data model mapping|
* +--------------+---------+-------------+------------------+
* | description | 7.19.3 | 0..1 | - string |
* | reference | 7.19.4 | 0..1 | - string |
* | status | 7.19.2 | 0..1 | - YangStatus |
* | position | 9.7.4.2 | 0..1 | - int |
* +--------------+---------+-------------+------------------+
*/
/**
* Maintains the bit data type information.
*/
public class YangBit implements YangCommonInfo, Parsable {
/**
* Name of the bit.
*/
private String bitName;
/**
* Description of the bit field.
*/
private String description;
/**
* reference info of the bit field.
*/
private String reference;
/**
* Status of the bit field.
*/
private YangStatusType status;
/**
* position of the bit whose name bit is described.
*/
private int position;
/**
* Create a YANG bit type object.
*/
public YangBit() {
}
/**
* Get the bit name.
*
* @return the bit name.
*/
public String getBitName() {
return bitName;
}
/**
* Set the bit name.
*
* @param bitName the bit name to set.
*/
public void setBitName(String bitName) {
this.bitName = bitName;
}
/**
* Get the description.
*
* @return the description.
*/
public String getDescription() {
return description;
}
/**
* Set the description.
*
* @param description set the description.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Get the textual reference.
*
* @return the reference.
*/
public String getReference() {
return reference;
}
/**
* Set the textual reference.
*
* @param reference the reference to set.
*/
public void setReference(String reference) {
this.reference = reference;
}
/**
* Get the status.
*
* @return the status.
*/
public YangStatusType getStatus() {
return status;
}
/**
* Set the status.
*
* @param status the status to set.
*/
public void setStatus(YangStatusType status) {
this.status = status;
}
/**
* Get the bit position.
*
* @return the position
*/
public int getPosition() {
return position;
}
/**
* Set the bit position.
*
* @param position the position to set.
*/
public void setPosition(int position) {
this.position = position;
}
/**
* Returns the type of the data.
*
* @return ParsedDataType returns BIT_DATA
*/
public ParsableDataType getParsableDataType() {
return ParsableDataType.BIT_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
}
/*
* 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 java.util.HashSet;
import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
/*
* Reference RFC 6020.
*
* The bits built-in type represents a bit set. That is, a bits value
* is a set of flags identified by small integer position numbers
* starting at 0. Each bit number has an assigned name.
*/
/**
* Maintains the bits data type information.
*/
public class YangBits implements Parsable {
private Set<YangBit> bitSet;
/**
* Create a YANG bits type object.
*/
public YangBits() {
setBitSet(new HashSet<YangBit>());
}
/**
* Get the bit set.
*
* @return the bit set
*/
public Set<YangBit> getBitSet() {
return bitSet;
}
/**
* set the bit set.
*
* @param bitSet the bit set
*/
private void setBitSet(Set<YangBit> bitSet) {
this.bitSet = bitSet;
}
/**
* Add bit info.
*
* @param bitInfo the bit Info to add.
*/
public void addBitInfo(YangBit bitInfo) {
getBitSet().add(bitInfo);
}
/**
* Returns the type of the data.
*
* @return ParsedDataType returns BITS_DATA
*/
public ParsableDataType getParsableDataType() {
return ParsableDataType.BITS_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
}
/*
* 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 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;
/*-
* Reference RFC 6020.
*
* The "case" statement is used to define branches of the choice. It takes as an
* argument an identifier, followed by a block of sub-statements that holds
* detailed case information.
*
* The identifier is used to identify the case node in the schema tree. A case
* node does not exist in the data tree.
*
* Within a "case" statement, the "anyxml", "choice", "container", "leaf",
* "list", "leaf-list", and "uses" statements can be used to define child nodes
* to the case node. The identifiers of all these child nodes MUST be unique
* within all cases in a choice. For example, the following is illegal:
*
* choice interface-type { // This example is illegal YANG
* case a {
* leaf ethernet { ... }
* }
* case b {
* container ethernet { ...}
* }
* }
*
* As a shorthand, the "case" statement can be omitted if the branch
* contains a single "anyxml", "container", "leaf", "list", or
* "leaf-list" statement. In this case, the identifier of the case node
* is the same as the identifier in the branch statement. The following
* example:
*
* choice interface-type {
* container ethernet { ... }
* }
*
* is equivalent to:
*
* choice interface-type {
* case ethernet {
* container ethernet { ... }
* }
* }
*
* The case identifier MUST be unique within a choice.
*
* The case's sub-statements
*
* +--------------+---------+-------------+------------------+
* | substatement | section | cardinality |data model mapping|
* +--------------+---------+-------------+------------------+
* | anyxml | 7.10 | 0..n |-not supported |
* | choice | 7.9 | 0..n |-child nodes |
* | container | 7.5 | 0..n |-child nodes |
* | description | 7.19.3 | 0..1 |-string |
* | if-feature | 7.18.2 | 0..n |-TODO |
* | leaf | 7.6 | 0..n |-YangLeaf |
* | leaf-list | 7.7 | 0..n |-YangLeafList |
* | list | 7.8 | 0..n |-child nodes |
* | reference | 7.19.4 | 0..1 |-string |
* | status | 7.19.2 | 0..1 |-YangStatus |
* | uses | 7.12 | 0..n |-child node |
* | when | 7.19.5 | 0..1 |-TODO |
* +--------------+---------+-------------+------------------+
*/
/**
* Data model node to maintain information defined in YANG case.
*/
public class YangCase extends YangNode
implements YangLeavesHolder, YangCommonInfo, Parsable {
/**
* Case name.
*/
private String name;
// TODO: default field identification for the case
/**
* Description of container.
*/
private String description;
/**
* List of leaves.
*/
@SuppressWarnings("rawtypes")
private List<YangLeaf> listOfLeaf;
/**
* List of leaf lists.
*/
@SuppressWarnings("rawtypes")
private List<YangLeafList> listOfLeafList;
/**
* Reference of the module.
*/
private String reference;
/**
* Status of the node.
*/
private YangStatusType status;
/**
* Create a choice node.
*/
public YangCase() {
super(YangNodeType.CASE_NODE);
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
*/
@Override
public String getName() {
return name;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
*/
@Override
public void setName(String name) {
this.name = name;
}
/**
* Get the description.
*
* @return the description.
*/
public String getDescription() {
return description;
}
/**
* Set the description.
*
* @param description set the description.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Get the list of leaves.
*
* @return the list of leaves.
*/
@SuppressWarnings("rawtypes")
public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
/**
* Set the list of leaves.
*
* @param leafsList the list of leaf to set.
*/
@SuppressWarnings("rawtypes")
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
/**
* Add a leaf.
*
* @param leaf the leaf to be added.
*/
@SuppressWarnings("rawtypes")
public void addLeaf(YangLeaf<?> leaf) {
if (getListOfLeaf() == null) {
setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
}
/**
* Get the list of leaf-list.
*
* @return the list of leaf-list.
*/
@SuppressWarnings("rawtypes")
public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
/**
* Set the list of leaf-list.
*
* @param listOfLeafList the list of leaf-list to set.
*/
@SuppressWarnings("rawtypes")
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
/**
* Add a leaf-list.
*
* @param leafList the leaf-list to be added.
*/
@SuppressWarnings("rawtypes")
public void addLeafList(YangLeafList<?> leafList) {
if (getListOfLeafList() == null) {
setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
}
/**
* Get the textual reference.
*
* @return the reference.
*/
public String getReference() {
return reference;
}
/**
* Set the textual reference.
*
* @param reference the reference to set.
*/
public void setReference(String reference) {
this.reference = reference;
}
/**
* Get the status.
*
* @return the status.
*/
public YangStatusType getStatus() {
return status;
}
/**
* Set the status.
*
* @param status the status to set.
*/
public void setStatus(YangStatusType status) {
this.status = status;
}
/**
* Returns the type of the data.
*
* @return returns CASE_DATA
*/
public ParsableDataType getParsableDataType() {
return ParsableDataType.CASE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
*/
public void generateJavaCodeEntry() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
*/
public void generateJavaCodeExit() {
// TODO Auto-generated method stub
}
}
/*
* 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 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;
/*-
* Reference RFC 6020.
*
* The "choice" statement defines a set of alternatives, only one of
* which may exist at any one time. The argument is an identifier,
* followed by a block of sub-statements that holds detailed choice
* information. The identifier is used to identify the choice node in
* the schema tree. A choice node does not exist in the data tree.
*
* A choice consists of a number of branches, defined with the "case"
* sub-statement. Each branch contains a number of child nodes. The
* nodes from at most one of the choice's branches exist at the same
* time.
*
* The choice's sub-statements
*
* +--------------+---------+-------------+------------------+
* | substatement | section | cardinality |data model mapping|
* +--------------+---------+-------------+------------------+
* | anyxml | 7.10 | 0..n |-not supported |
* | case | 7.9.2 | 0..n |-YangChoice |
* | config | 7.19.1 | 0..1 |-boolean |
* | container | 7.5 | 0..n |-child case nodes |
* | default | 7.9.3 | 0..1 |-string |
* | description | 7.19.3 | 0..1 |-string |
* | if-feature | 7.18.2 | 0..n |-TODO |
* | leaf | 7.6 | 0..n |-child case nodes |
* | leaf-list | 7.7 | 0..n |-child case nodes |
* | list | 7.8 | 0..n |-child case nodes |
* | mandatory | 7.9.4 | 0..1 |-string |
* | reference | 7.19.4 | 0..1 |-string |
* | status | 7.19.2 | 0..1 |-string |
* | when | 7.19.5 | 0..1 |-TODO |
* +--------------+---------+-------------+------------------+
*/
/**
* Data model node to maintain information defined in YANG choice.
*/
public class YangChoice extends YangNode implements YangCommonInfo, Parsable {
/**
* Name of choice.
*/
private String name;
/**
* List of cases for the current choice.
*/
private List<YangCase> caseList;
/**
* If the choice represents config data.
*/
private boolean isConfig;
/**
* Reference RFC 6020.
*
* The "default" statement indicates if a case should be considered as the
* default if no child nodes from any of the choice's cases exist. The
* argument is the identifier of the "case" statement. If the "default"
* statement is missing, there is no default case.
*
* The "default" statement MUST NOT be present on choices where "mandatory"
* is true.
*
* The default case is only important when considering the default values of
* nodes under the cases. The default values for nodes under the default
* case are used if none of the nodes under any of the cases are present.
*
* There MUST NOT be any mandatory nodes directly under the default case.
*
* Default values for child nodes under a case are only used if one of the
* nodes under that case is present, or if that case is the default case. If
* none of the nodes under a case are present and the case is not the
* default case, the default values of the cases' child nodes are ignored.
*
* the default case to be used if no case members is present.
*/
private String defaultCase;
/**
* Description.
*/
private String description;
/**
* Reference RFC 6020.
*
* The "mandatory" statement, which is optional, takes as an argument the
* string "true" or "false", and puts a constraint on valid data. If
* "mandatory" is "true", at least one node from exactly one of the choice's
* case branches MUST exist.
*
* If not specified, the default is "false".
*
* The behavior of the constraint depends on the type of the choice's
* closest ancestor node in the schema tree which is not a non-presence
* container:
*
* o If this ancestor is a case node, the constraint is enforced if any
* other node from the case exists.
*
* o Otherwise, it is enforced if the ancestor node exists.
*/
private String mandatory;
/**
* reference of the choice.
*/
private String reference;
/**
* Status of the node.
*/
private YangStatusType status;
/**
* Create a Choice node.
*/
public YangChoice() {
super(YangNodeType.CHOICE_NODE);
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
*/
@Override
public String getName() {
return name;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
*/
@Override
public void setName(String name) {
this.name = name;
}
/**
* 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.
*/
public boolean isConfig() {
return isConfig;
}
/**
* Set config flag.
*
* @param isCfg the config flag.
*/
public void setConfig(boolean isCfg) {
isConfig = isCfg;
}
/**
* Get the default case.
*
* @return the default case.
*/
public String getDefaultCase() {
return defaultCase;
}
/**
* Set the default case.
*
* @param defaultCase the default case to set
*/
public void setDefaultCase(String defaultCase) {
this.defaultCase = defaultCase;
}
/**
* Get the mandatory status.
*
* @return the mandatory status.
*/
public String getMandatory() {
return mandatory;
}
/**
* Set the mandatory status.
*
* @param mandatory the mandatory status.
*/
public void setMandatory(String mandatory) {
this.mandatory = mandatory;
}
/**
* Get the description.
*
* @return the description.
*/
public String getDescription() {
return description;
}
/**
* Set the description.
*
* @param description set the description.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Get the textual reference.
*
* @return the reference.
*/
public String getReference() {
return reference;
}
/**
* Set the textual reference.
*
* @param reference the reference to set.
*/
public void setReference(String reference) {
this.reference = reference;
}
/**
* Get the status.
*
* @return the status.
*/
public YangStatusType getStatus() {
return status;
}
/**
* Set the status.
*
* @param status the status to set.
*/
public void setStatus(YangStatusType status) {
this.status = status;
}
/**
* Returns the type of the data.
*
* @return returns CHOICE_DATA
*/
public ParsableDataType getParsableDataType() {
return ParsableDataType.CHOICE_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
*/
public void generateJavaCodeEntry() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
*/
public void generateJavaCodeExit() {
// TODO Auto-generated method stub
}
}
/*
* 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.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
/*-
* The "ENUM" statement, which is a sub-statement to the "type"
* statement, MUST be present if the type is "enumeration". It is
* repeatedly used to specify each assigned name of an enumeration type.
* It takes as an argument a string which is the assigned name. The
* string MUST NOT be empty and MUST NOT have any leading or trailing
* whitespace characters. The use of Unicode control codes SHOULD be
* avoided.
*
* The statement is optionally followed by a block of sub-statements that
* holds detailed ENUM information.
* All assigned names in an enumeration MUST be unique.
*
* The ENUM's sub-statements
*
* +--------------+---------+-------------+------------------+
* | substatement | section | cardinality |data model mapping|
* +--------------+---------+-------------+------------------+
* | description | 7.19.3 | 0..1 | - string |
* | reference | 7.19.4 | 0..1 | - string |
* | status | 7.19.2 | 0..1 | - YangStatus |
* | value | 9.6.4.2 | 0..1 | - int |
* +--------------+---------+-------------+------------------+
*/
/**
* Maintains the ENUM data type information.
*/
public class YangEnum implements YangCommonInfo, Parsable {
/**
* Named value for the ENUM.
*/
private String namedValue;
/**
* Description of the ENUM value.
*/
private String description;
/**
* Reference info of the ENUM value.
*/
private String reference;
/**
* Status of the ENUM value.
*/
private YangStatusType status;
/**
* value of ENUM.
*/
private int value;
/**
* Create a YANG ENUM.
*/
public YangEnum() {
}
/**
* Get the named value.
*
* @return the named value.
*/
public String getNamedValue() {
return namedValue;
}
/**
* Set the named value.
*
* @param namedValue the named value to set.
*/
public void setNamedValue(String namedValue) {
this.namedValue = namedValue;
}
/**
* Get the description.
*
* @return the description.
*/
public String getDescription() {
return description;
}
/**
* Set the description.
*
* @param description set the description.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Get the textual reference.
*
* @return the reference.
*/
public String getReference() {
return reference;
}
/**
* Set the textual reference.
*
* @param reference the reference to set.
*/
public void setReference(String reference) {
this.reference = reference;
}
/**
* Get the status.
*
* @return the status.
*/
public YangStatusType getStatus() {
return status;
}
/**
* Set the status.
*
* @param status the status to set.
*/
public void setStatus(YangStatusType status) {
this.status = status;
}
/**
* Get the value.
*
* @return the value.
*/
public int getValue() {
return value;
}
/**
* Set the value.
*
* @param value the value to set.
*/
public void setValue(int value) {
this.value = value;
}
/**
* Returns the type of the data.
*
* @return ParsedDataType returns ENUM_DATA
*/
public ParsableDataType getParsableDataType() {
return ParsableDataType.ENUM_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
}
/*
* 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 java.util.HashSet;
import java.util.Set;
import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
/*
* The enumeration built-in type represents values from a set of
* assigned names.
*/
/**
* Maintains the enumeration data type information.
*/
public class YangEnumeration extends YangNode implements Parsable {
/**
* Enumeration info set.
*/
private Set<YangEnum> enumSet;
/**
* Create an enumeration object.
*/
public YangEnumeration() {
super(YangNodeType.ENUMERATION_NODE);
setEnumSet(new HashSet<YangEnum>());
}
/**
* Get the ENUM set.
*
* @return the ENUM set
*/
public Set<YangEnum> getEnumSet() {
return enumSet;
}
/**
* Set the ENUM set.
*
* @param enumSet the ENUM set to set
*/
private void setEnumSet(Set<YangEnum> enumSet) {
this.enumSet = enumSet;
}
/**
* Add ENUM value.
*
* @param enumInfo the ENUM value of string
*/
public void addEnumInfo(YangEnum enumInfo) {
}
/**
* Returns the type of the data.
*
* @return returns ENUMERATION_DATA
*/
public ParsableDataType getParsableDataType() {
return ParsableDataType.ENUMERATION_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
*/
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
*/
@Override
public void setName(String name) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
*/
public void generateJavaCodeEntry() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
*/
public void generateJavaCodeExit() {
// TODO Auto-generated method stub
}
}
/*
* 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 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;
/*-
* Reference RFC 6020.
*
* The "grouping" statement is used to define a reusable block of nodes,
* which may be used locally in the module, in modules that include it,
* and by other modules that import from it. It takes one argument,
* which is an identifier, followed by a block of sub-statements that
* holds detailed grouping information.
*
* The "grouping" statement is not a data definition statement and, as
* such, does not define any nodes in the schema tree.
*
* A grouping is like a "structure" or a "record" in conventional
* programming languages.
* Once a grouping is defined, it can be referenced in a "uses"
* statement. A grouping MUST NOT reference itself,
* neither directly nor indirectly through a chain of other groupings.
*
* If the grouping is defined at the top level of a YANG module or
* submodule, the grouping's identifier MUST be unique within the
* module.
*
* A grouping is more than just a mechanism for textual substitution,
* but defines a collection of nodes. Identifiers appearing inside the
* grouping are resolved relative to the scope in which the grouping is
* defined, not where it is used. Prefix mappings, type names, grouping
* names, and extension usage are evaluated in the hierarchy where the
* "grouping" statement appears. For extensions, this means that
* extensions are applied to the grouping node, not the uses node.
*
* The grouping's sub-statements
*
* +--------------+---------+-------------+------------------+
* | substatement | section | cardinality |data model mapping|
* +--------------+---------+-------------+------------------+
* | anyxml | 7.10 | 0..n |-not supported |
* | choice | 7.9 | 0..n |-child nodes |
* | container | 7.5 | 0..n |-child nodes |
* | description | 7.19.3 | 0..1 |-string |
* | grouping | 7.11 | 0..n |-child nodes |
* | leaf | 7.6 | 0..n |-YangLeaf |
* | leaf-list | 7.7 | 0..n |-YangLeafList |
* | list | 7.8 | 0..n |-child nodes |
* | reference | 7.19.4 | 0..1 |-string |
* | status | 7.19.2 | 0..1 |-YangStatus |
* | typedef | 7.3 | 0..n |-child nodes |
* | uses | 7.12 | 0..n |-child nodes |
* +--------------+---------+-------------+------------------+
*/
/**
* Data model node to maintain information defined in YANG grouping.
*/
public class YangGrouping extends YangNode
implements YangLeavesHolder, YangCommonInfo, Parsable {
/**
* Name of the grouping.
*/
private String name;
/**
* Description.
*/
private String description;
/**
* List of leaves.
*/
@SuppressWarnings("rawtypes")
private List<YangLeaf> listOfLeaf;
/**
* List of leaf lists.
*/
@SuppressWarnings("rawtypes")
private List<YangLeafList> listOfLeafList;
/**
* Reference of the module.
*/
private String reference;
/**
* Status of the node.
*/
private YangStatusType status;
/**
* Creates the grouping node.
*/
public YangGrouping() {
super(YangNodeType.GROUPING_NODE);
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
*/
@Override
public String getName() {
return name;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
*/
@Override
public void setName(String name) {
this.name = name;
}
/**
* Get the description.
*
* @return the description.
*/
public String getDescription() {
return description;
}
/**
* Set the description.
*
* @param description set the description.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Get the list of leaves.
*
* @return the list of leaves.
*/
@SuppressWarnings("rawtypes")
public List<YangLeaf> getListOfLeaf() {
return listOfLeaf;
}
/**
* Set the list of leaves.
*
* @param leafsList the list of leaf to set.
*/
@SuppressWarnings("rawtypes")
private void setListOfLeaf(List<YangLeaf> leafsList) {
listOfLeaf = leafsList;
}
/**
* Add a leaf.
*
* @param leaf the leaf to be added.
*/
@SuppressWarnings("rawtypes")
public void addLeaf(YangLeaf<?> leaf) {
if (getListOfLeaf() == null) {
setListOfLeaf(new LinkedList<YangLeaf>());
}
getListOfLeaf().add(leaf);
}
/**
* Get the list of leaf-list.
*
* @return the list of leaf-list.
*/
@SuppressWarnings("rawtypes")
public List<YangLeafList> getListOfLeafList() {
return listOfLeafList;
}
/**
* Set the list of leaf-list.
*
* @param listOfLeafList the list of leaf-list to set.
*/
@SuppressWarnings("rawtypes")
private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
this.listOfLeafList = listOfLeafList;
}
/**
* Add a leaf-list.
*
* @param leafList the leaf-list to be added.
*/
@SuppressWarnings("rawtypes")
public void addLeafList(YangLeafList<?> leafList) {
if (getListOfLeafList() == null) {
setListOfLeafList(new LinkedList<YangLeafList>());
}
getListOfLeafList().add(leafList);
}
/**
* Get the textual reference.
*
* @return the reference.
*/
public String getReference() {
return reference;
}
/**
* Set the textual reference.
*
* @param reference the reference to set.
*/
public void setReference(String reference) {
this.reference = reference;
}
/**
* Get the status.
*
* @return the status.
*/
public YangStatusType getStatus() {
return status;
}
/**
* Set the status.
*
* @param status the status to set.
*/
public void setStatus(YangStatusType status) {
this.status = status;
}
/**
* Returns the type of the data.
*
* @return returns GROUPING_DATA.
*/
public ParsableDataType getParsableDataType() {
return ParsableDataType.GROUPING_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
*/
public void generateJavaCodeEntry() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
*/
public void generateJavaCodeExit() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
}
}
/*
* 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.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
/*-
* The "must" statement, which is optional, takes as an argument a string that
* contains an XPath expression. It is used to formally declare a constraint
* on valid data.
*
* When a datastore is validated, all "must" constraints are conceptually
* evaluated once for each data node in the data tree, and for all leafs with
* default values in use. If a data node does not exist in the data tree, and
* it does not have a default value, its "must" statements are not evaluated.
*
* All such constraints MUST evaluate to true for the data to be valid.
*
* The must's sub-statements
*
* +---------------+---------+-------------+------------------+
* | substatement | section | cardinality |data model mapping|
* +---------------+---------+-------------+------------------+
* | description | 7.19.3 | 0..1 | -string |
* | error-app-tag | 7.5.4.2 | 0..1 | -not supported |
* | error-message | 7.5.4.1 | 0..1 | -not supported |
* | reference | 7.19.4 | 0..1 | -string |
* +---------------+---------+-------------+------------------+
*/
/**
* Maintain information defined in YANG must.
*/
public class YangMust implements YangDesc, YangReference, Parsable {
/**
* Constraint info.
*/
private String constratint;
/**
* Description string.
*/
private String description;
/**
* reference string.
*/
private String reference;
/**
* Create a YANG must restriction.
*/
public YangMust() {
}
/**
* Get the constraint.
*
* @return the constraint.
*/
public String getConstratint() {
return constratint;
}
/**
* Set the constraint.
*
* @param constratint the constraint to set
*/
public void setConstratint(String constratint) {
this.constratint = constratint;
}
/**
* Get the description.
*
* @return the description.
*/
public String getDescription() {
return description;
}
/**
* Set the description.
*
* @param description set the description.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Get the textual reference.
*
* @return the reference.
*/
public String getReference() {
return reference;
}
/**
* Set the textual reference.
*
* @param reference the reference to set.
*/
public void setReference(String reference) {
this.reference = reference;
}
/**
* Returns the type of the parsed data.
*
* @return returns MUST_DATA
*/
public ParsableDataType getParsableDataType() {
return ParsableDataType.MUST_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
}
/*
* 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.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
/*-
* Reference RFC 6020.
*
* The "typedef" statement defines a new type that may be used locally in the
* module, in modules or submodules which include it, and by other modules that
* import from it. The new type is called the "derived type", and the type from
* which it was derived is called the "base type". All derived types can be
* traced back to a YANG built-in type.
*
* The "typedef" statement's argument is an identifier that is the name of the
* type to be defined, and MUST be followed by a block of sub-statements that
* holds detailed typedef information.
*
* The name of the type MUST NOT be one of the YANG built-in types. If the
* typedef is defined at the top level of a YANG module or submodule, the name
* of the type to be defined MUST be unique within the module.
* The typedef's sub-statements
*
* +--------------+---------+-------------+------------------+
* | substatement | section | cardinality |data model mapping|
* +--------------+---------+-------------+------------------+
* | default | 7.3.4 | 0..1 |-string |
* | description | 7.19.3 | 0..1 |-string |
* | reference | 7.19.4 | 0..1 |-string |
* | status | 7.19.2 | 0..1 |-YangStatus |
* | type | 7.3.2 | 1 |-yangType |
* | units | 7.3.3 | 0..1 |-string |
* +--------------+---------+-------------+------------------+
*/
/**
* Data model node to maintain information defined in YANG typedef.
*/
public class YangTypeDef extends YangNode implements YangCommonInfo, Parsable {
/**
* Name of derived data type.
*/
private String derivedName;
/**
* Default value in string, needs to be converted to the target object,
* based on the type.
*/
private String defaultValueInString;
/**
* Description of new type.
*/
private String description;
/**
* reference string.
*/
private String reference;
/**
* Status of the data type.
*/
private YangStatusType status;
/**
* Derived data type.
*/
@SuppressWarnings("rawtypes")
private YangType derivedType;
/**
* Units of the data type.
*/
private String units;
/**
* Create a typedef node.
*/
public YangTypeDef() {
super(YangNodeType.TYPEDEF_NODE);
}
/**
* Get the data type name.
*
* @return the data type name.
*/
public String getDerivedName() {
return derivedName;
}
/**
* Set the data type name.
*
* @param derrivedName data type name.
*/
public void setDerivedName(String derrivedName) {
derivedName = derrivedName;
}
/**
* Get the default value.
*
* @return the default value.
*/
public String getDefaultValueInString() {
return defaultValueInString;
}
/**
* Set the default value.
*
* @param defaultValueInString the default value.
*/
public void setDefaultValueInString(String defaultValueInString) {
this.defaultValueInString = defaultValueInString;
}
/**
* Get the description.
*
* @return the description.
*/
public String getDescription() {
return description;
}
/**
* Set the description.
*
* @param description set the description.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Get the textual reference.
*
* @return the reference.
*/
public String getReference() {
return reference;
}
/**
* Set the textual reference.
*
* @param reference the reference to set.
*/
public void setReference(String reference) {
this.reference = reference;
}
/**
* Get the status.
*
* @return the status.
*/
public YangStatusType getStatus() {
return status;
}
/**
* Set the status.
*
* @param status the status to set.
*/
public void setStatus(YangStatusType status) {
this.status = status;
}
/**
* Get the referenced type.
*
* @return the referenced type.
*/
@SuppressWarnings("rawtypes")
public YangType getDerivedType() {
return derivedType;
}
/**
* Get the referenced type.
*
* @param derivedType the referenced type.
*/
@SuppressWarnings("rawtypes")
public void setDerivedType(YangType derivedType) {
this.derivedType = derivedType;
}
/**
* Get the unit.
*
* @return the units
*/
public String getUnits() {
return units;
}
/**
* Set the unit.
*
* @param units the units to set
*/
public void setUnits(String units) {
this.units = units;
}
/**
* Returns the type of the data.
*
* @return returns TYPEDEF_DATA
*/
public ParsableDataType getParsableDataType() {
return ParsableDataType.TYPEDEF_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
*/
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
*/
@Override
public void setName(String name) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
*/
public void generateJavaCodeEntry() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
*/
public void generateJavaCodeExit() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
}
}
/*
* 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.parser.Parsable;
import org.onosproject.yangutils.parser.ParsableDataType;
/*-
* Reference RFC 6020.
*
* The "uses" statement is used to reference a "grouping" definition. It takes
* one argument, which is the name of the grouping.
*
* The effect of a "uses" reference to a grouping is that the nodes defined by
* the grouping are copied into the current schema tree, and then updated
* according to the "refine" and "augment" statements.
*
* The identifiers defined in the grouping are not bound to a namespace until
* the contents of the grouping are added to the schema tree via a "uses"
* statement that does not appear inside a "grouping" statement, at which point
* they are bound to the namespace of the current module.
*
* The uses's sub-statements
*
* +--------------+---------+-------------+------------------+
* | substatement | section | cardinality |data model mapping|
* +--------------+---------+-------------+------------------+
* | augment | 7.15 | 0..1 | -child nodes |
* | description | 7.19.3 | 0..1 | -string |
* | if-feature | 7.18.2 | 0..n | -TODO |
* | refine | 7.12.2 | 0..1 | -TODO |
* | reference | 7.19.4 | 0..1 | -string |
* | status | 7.19.2 | 0..1 | -YangStatus |
* | when | 7.19.5 | 0..1 | -TODO |
* +--------------+---------+-------------+------------------+
*/
/**
* Data model node to maintain information defined in YANG uses.
*
*/
public class YangUses extends YangNode implements YangCommonInfo, Parsable {
/**
* Name.
*/
private String name;
/**
* referred group.
*/
private YangGrouping refGroup;
/**
* description.
*/
private String description;
/**
* YANG reference.
*/
private String reference;
/**
* Status.
*/
private YangStatusType status;
/**
* Create an YANG uses node.
*/
public YangUses() {
super(YangNodeType.USES_NODE);
}
/**
* Get the name.
*
* @return the name.
*/
public String getRefGroupingName() {
return name;
}
/**
* Set the name.
*
* @param refGroupingName the referred grouping name to set
*/
public void setRefGroupingName(String refGroupingName) {
name = refGroupingName;
}
/**
* Get the referred group.
*
* @return the referred group.
*/
public YangGrouping getRefGroup() {
return refGroup;
}
/**
* Set the referred group.
*
* @param refGroup the referred group.
*/
public void setRefGroup(YangGrouping refGroup) {
this.refGroup = refGroup;
}
/**
* Get the description.
*
* @return the description.
*/
public String getDescription() {
return description;
}
/**
* Set the description.
*
* @param description set the description.
*/
public void setDescription(String description) {
this.description = description;
}
/**
* Get the textual reference.
*
* @return the reference.
*/
public String getReference() {
return reference;
}
/**
* Set the textual reference.
*
* @param reference the reference to set.
*/
public void setReference(String reference) {
this.reference = reference;
}
/**
* Get the status.
*
* @return the status.
*/
public YangStatusType getStatus() {
return status;
}
/**
* Set the status.
*
* @param status the status to set.
*/
public void setStatus(YangStatusType status) {
this.status = status;
}
/**
* Returns the type of the data.
*
* @return returns USES_DATA.
*/
public ParsableDataType getParsableDataType() {
return ParsableDataType.USES_DATA;
}
/**
* Validate the data on entering the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnEntry() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/**
* Validate the data on exiting the corresponding parse tree node.
*
* @throws DataModelException a violation of data model rules.
*/
public void validateDataOnExit() throws DataModelException {
// TODO auto-generated method stub, to be implemented by parser
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getName()
*/
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setName(java.lang.String)
*/
@Override
public void setName(String name) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeEntry()
*/
public void generateJavaCodeEntry() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.translator.CodeGenerator#generateJavaCodeExit()
*/
public void generateJavaCodeExit() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#getPackage()
*/
@Override
public String getPackage() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.onosproject.yangutils.datamodel.YangNode#setPackage(java.lang.String)
*/
@Override
public void setPackage(String pkg) {
// TODO Auto-generated method stub
}
}