null
. null
values) the method will throw
* IllegalArgumentException.
*
* @param context
* Schema Context
* @param schemaPath
* Schema Path to search for
* @return SchemaNode from the end of the Schema Path or null
* if the Node is not present.
* @throws IllegalArgumentException if context or schemaPath is not correct.
*/
public static SchemaNode findDataSchemaNode(final SchemaContext context, final SchemaPath schemaPath) {
Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
Preconditions.checkArgument(schemaPath != null, "Schema Path reference cannot be NULL");
final Iterablenull
. null
references the method will throw
* IllegalArgumentException null
.
*
* @param context
* Schema Context
* @param module
* Yang Module
* @param nonCondXPath
* Non Conditional Revision Aware XPath
* @return Returns Data Schema Node for specified Schema Context for given
* Non-conditional Revision Aware XPath, or null
if the
* DataSchemaNode is not present in Schema Context.
*/
public static SchemaNode findDataSchemaNode(final SchemaContext context, final Module module,
final RevisionAwareXPath nonCondXPath) {
Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
Preconditions.checkArgument(nonCondXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
final String strXPath = nonCondXPath.toString();
if (strXPath != null) {
Preconditions.checkArgument(strXPath.indexOf('[') == -1,
"Revision Aware XPath may not contain a condition");
if (nonCondXPath.isAbsolute()) {
final Listnull
. null
references the method
* will throw IllegalArgumentException isAbsolute == false
the method will throw
* IllegalArgumentException. null
.
*
* @param context
* Schema Context
* @param module
* Yang Module
* @param actualSchemaNode
* Actual Schema Node
* @param relativeXPath
* Relative Non Conditional Revision Aware XPath
* @return DataSchemaNode if is present in specified Schema Context for
* given relative Revision Aware XPath, otherwise will return
* null
.
*/
public static SchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context, final Module module,
final SchemaNode actualSchemaNode, final RevisionAwareXPath relativeXPath) {
Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
Preconditions.checkArgument(actualSchemaNode != null, "Actual Schema Node reference cannot be NULL");
Preconditions.checkArgument(relativeXPath != null, "Non Conditional Revision Aware XPath cannot be NULL");
Preconditions.checkState(!relativeXPath.isAbsolute(),
"Revision Aware XPath MUST be relative i.e. MUST contains ../, "
+ "for non relative Revision Aware XPath use findDataSchemaNode method");
final SchemaPath actualNodePath = actualSchemaNode.getPath();
if (actualNodePath != null) {
final Iterablenull
. null
references
* the method will throw IllegalArgumentException
*
* @param context
* Schema Context
* @param schemaNode
* Schema Node
* @return Yang Module for specified Schema Context and Schema Node, if Schema Node is NOT present, the method will
* return null
*/
public static Module findParentModule(final SchemaContext context, final SchemaNode schemaNode) {
Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL!");
Preconditions.checkArgument(schemaNode != null, "Schema Node cannot be NULL!");
Preconditions.checkState(schemaNode.getPath() != null, "Schema Path for Schema Node is not "
+ "set properly (Schema Path is NULL)");
final QName qname = schemaNode.getPath().getLastComponent();
Preconditions.checkState(qname != null, "Schema Path contains invalid state of path parts. "
+ "The Schema Path MUST contain at least ONE QName which defines namespace and Local name of path.");
return context.findModule(qname.getModule()).orElse(null);
}
public static SchemaNode findNodeInSchemaContext(final SchemaContext context, final Iterablenull
values, the method will throws IllegalArgumentException
*
* @param context
* Schema Context
* @param parentModule
* Parent Module
* @param xpath
* XPath String
* @return return a list of QName
*
* @throws IllegalArgumentException if any arguments are null
*
*/
private static Listnull
the method will throw IllegalArgumentException
*
* @param context
* Schema Context
* @param parentModule
* Parent Module
* @param prefixedPathPart
* Prefixed Path Part string
* @return QName from prefixed Path Part String.
* @throws IllegalArgumentException if any arguments are null
*/
private static QName stringPathPartToQName(final SchemaContext context, final Module parentModule,
final String prefixedPathPart) {
// FIXME: 2.0.0: this should throw NPE, not IAE
Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
Preconditions.checkArgument(parentModule != null, "Parent Module reference cannot be NULL");
Preconditions.checkArgument(prefixedPathPart != null, "Prefixed Path Part cannot be NULL!");
if (prefixedPathPart.indexOf(':') != -1) {
final Iteratornull
. null
* the method will return IllegalArgumentException
*
* @param context
* Schema Context
* @param module
* Yang Module
* @param prefix
* Module Prefix
* @return Module for given prefix in specified Schema Context if is
* present, otherwise returns null
* @throws IllegalArgumentException if any arguments are null
*/
private static Module resolveModuleForPrefix(final SchemaContext context, final Module module,
final String prefix) {
// FIXME: 2.0.0: this should throw NPE, not IAE
Preconditions.checkArgument(context != null, "Schema Context reference cannot be NULL");
Preconditions.checkArgument(module != null, "Module reference cannot be NULL");
Preconditions.checkArgument(prefix != null, "Prefix string cannot be NULL");
if (prefix.equals(module.getPrefix())) {
return module;
}
final Set
* Because {@code typeDefinition} is definied via typedef statement, only absolute path is meaningful.
*/
public static TypeDefinition> getBaseTypeForLeafRef(final LeafrefTypeDefinition typeDefinition,
final SchemaContext schemaContext, final QName qname) {
final RevisionAwareXPath pathStatement = typeDefinition.getPathStatement();
final RevisionAwareXPath strippedPathStatement = new RevisionAwareXPathImpl(
stripConditionsFromXPathString(pathStatement), pathStatement.isAbsolute());
if (!strippedPathStatement.isAbsolute()) {
return null;
}
final Optional