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 NullPointerException if context or schemaPath is null
*/
public static SchemaNode findDataSchemaNode(final SchemaContext context, final SchemaPath schemaPath) {
final Iterablenull
. 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.
* @throws NullPointerException if any of the arguments is null
*/
// FIXME: This entire method is ill-defined, as the resolution process depends on where the XPath is defined --
// notably RPCs, actions and notifications modify the data tree temporarily. See sections 6.4.1 and 9.9.2
// of RFC7950.
//
// Most notably we need to understand whether the XPath is being resolved in the data tree, or as part of
// a notification/action/RPC, as then the SchemaContext grows tentative nodes ... which could be addressed
// via a derived SchemaContext (i.e. this class would have to have a
//
// SchemaContext notificationSchemaContext(SchemaContext delegate, NotificationDefinition notif)
//
// which would then be passed in to a method similar to this one. In static contexts, like MD-SAL codegen,
// that feels like an overkill.
public static SchemaNode findDataSchemaNode(final SchemaContext context, final Module module,
final PathExpression nonCondXPath) {
requireNonNull(context, "context");
requireNonNull(module, "module");
final String strXPath = nonCondXPath.getOriginalString();
checkArgument(strXPath.indexOf('[') == -1, "Revision Aware XPath may not contain a condition");
if (nonCondXPath.isAbsolute()) {
return findTargetNode(context, xpathToQNamePath(context, module, strXPath));
}
return null;
}
/**
* Method attempts to find DataSchemaNode inside of provided Schema Context
* and Yang Module accordingly to Non-conditional relative Revision Aware
* XPath. The specified Module MUST be present in Schema Context otherwise
* the operation would fail and return null
. 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
.
* @throws NullPointerException if any argument is null
*/
// FIXME: This entire method is ill-defined, as the resolution process depends on where the XPath is defined --
// notably RPCs, actions and notifications modify the data tree temporarily. See sections 6.4.1 and 9.9.2
// of RFC7950.
//
// Most notably we need to understand whether the XPath is being resolved in the data tree, or as part of
// a notification/action/RPC, as then the SchemaContext grows tentative nodes ... which could be addressed
// via a derived SchemaContext (i.e. this class would have to have a
//
// SchemaContext notificationSchemaContext(SchemaContext delegate, NotificationDefinition notif)
//
// which would then be passed in to a method similar to this one. In static contexts, like MD-SAL codegen,
// that feels like an overkill.
// FIXME: YANGTOOLS-1052: this is a static analysis util, move it to yang-model-sa
public static SchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context, final Module module,
final SchemaNode actualSchemaNode, final PathExpression relativeXPath) {
checkState(!relativeXPath.isAbsolute(), "Revision Aware XPath MUST be relative i.e. MUST contains ../, "
+ "for non relative Revision Aware XPath use findDataSchemaNode method");
return resolveRelativeXPath(context, module, relativeXPath, actualSchemaNode);
}
/**
* Returns parent Yang Module for specified Schema Context in which Schema
* Node is declared. If the Schema Node is not present in Schema Context the
* operation will return null
.
*
* @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
* @throws NullPointerException if any of the arguments is null
*/
public static Module findParentModule(final SchemaContext context, final SchemaNode schemaNode) {
final QName qname = schemaNode.getPath().getLastComponent();
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
*/
private static Listnull
* @throws NullPointerException if any arguments are null
*/
private static Module resolveModuleForPrefix(final SchemaContext context, final Module module,
final String prefix) {
requireNonNull(context, "context");
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 PathExpression pathStatement = typeDefinition.getPathStatement();
final PathExpression strippedPathStatement = new PathExpressionImpl(
stripConditionsFromXPathString(pathStatement), pathStatement.isAbsolute());
if (!strippedPathStatement.isAbsolute()) {
return null;
}
final Optional