Class SchemaContextUtil
- java.lang.Object
-
- org.opendaylight.yangtools.yang.model.util.SchemaContextUtil
-
public final class SchemaContextUtil extends Object
The Schema Context Util contains support methods for searching through Schema Context modules for specified schema nodes via Schema Path or Revision Aware XPath. The Schema Context Util is designed as mixin, so it is not instantiable.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static SchemaNode
findDataSchemaNode(SchemaContext context, List<QName> path)
Attempt to find a DataSchemaNode based on its path from root, similar tofindDataSchemaNode(SchemaContext, Module, PathExpression)
without requiring an expression.static SchemaNode
findDataSchemaNode(SchemaContext context, QName... path)
Attempt to find a DataSchemaNode based on its path from root, similar tofindDataSchemaNode(SchemaContext, Module, PathExpression)
without requiring an expression.static SchemaNode
findDataSchemaNode(SchemaContext context, Module module, PathExpression nonCondXPath)
static SchemaNode
findDataSchemaNode(SchemaContext context, SchemaPath schemaPath)
Method attempts to find DataSchemaNode in Schema Context via specified Schema Path.static SchemaNode
findDataSchemaNodeForRelativeXPath(SchemaContext context, Module module, SchemaNode actualSchemaNode, PathExpression relativeXPath)
Method attempts to find DataSchemaNode inside of provided Schema Context and Yang Module accordingly to Non-conditional relative Revision Aware XPath.static SchemaNode
findDataTreeSchemaNode(SchemaContext ctx, QNameModule localModule, PathExpression absPath)
static SchemaNode
findDataTreeSchemaNode(SchemaContext ctx, QNameModule localModule, YangLocationPath absPath)
static SchemaNode
findNodeInSchemaContext(SchemaContext context, Iterable<QName> path)
static Module
findParentModule(SchemaContext context, SchemaNode schemaNode)
Returns parent Yang Module for specified Schema Context in which Schema Node is declared.static TypeDefinition<?>
getBaseTypeForLeafRef(LeafrefTypeDefinition typeDefinition, SchemaContext schemaContext, QName qname)
Returns base type fortypeDefinition
which belongs to module specified viaqname
.static TypeDefinition<?>
getBaseTypeForLeafRef(LeafrefTypeDefinition typeDefinition, SchemaContext schemaContext, SchemaNode schema)
Extracts the base type of node on which schema node points to.static Set<SourceIdentifier>
getConstituentModuleIdentifiers(SchemaContext context)
Extract the identifiers of all modules and submodules which were used to create a particular SchemaContext.static @Nullable NotificationDefinition
getNotificationSchema(@NonNull SchemaContext schema, @NonNull SchemaPath path)
Returns NotificationDefinition from Schema Context.static @Nullable ContainerSchemaNode
getRpcDataSchema(@NonNull SchemaContext schema, @NonNull SchemaPath path)
Returns RPC Input or Output Data container from RPC definition.
-
-
-
Method Detail
-
findDataSchemaNode
public static SchemaNode findDataSchemaNode(SchemaContext context, SchemaPath schemaPath)
Method attempts to find DataSchemaNode in Schema Context via specified Schema Path. The returned DataSchemaNode from method will be the node at the end of the SchemaPath. If the DataSchemaNode is not present in the Schema Context the method will returnnull
.In case that Schema Context or Schema Path are not specified correctly (i.e. contains
null
values) the method will throw IllegalArgumentException.- Parameters:
context
- Schema ContextschemaPath
- Schema Path to search for- Returns:
- SchemaNode from the end of the Schema Path or
null
if the Node is not present. - Throws:
NullPointerException
- if context or schemaPath is null
-
findDataSchemaNode
@Beta public static SchemaNode findDataSchemaNode(SchemaContext context, List<QName> path)
Attempt to find a DataSchemaNode based on its path from root, similar tofindDataSchemaNode(SchemaContext, Module, PathExpression)
without requiring an expression.- Parameters:
context
- Schema Contextpath
- Path to search for- Returns:
- SchemaNode from the end of the Schema Path or
null
if the Node is not present. - Throws:
NullPointerException
- if a any argument is null or if the path contains a null element
-
findDataSchemaNode
@Beta public static SchemaNode findDataSchemaNode(SchemaContext context, QName... path)
Attempt to find a DataSchemaNode based on its path from root, similar tofindDataSchemaNode(SchemaContext, Module, PathExpression)
without requiring an expression.- Parameters:
context
- Schema Contextpath
- Path to search for- Returns:
- SchemaNode from the end of the Schema Path or
null
if the Node is not present. - Throws:
NullPointerException
- if a any argument is null or if the path contains a null element
-
findDataSchemaNode
@Deprecated public static SchemaNode findDataSchemaNode(SchemaContext context, Module module, PathExpression nonCondXPath)
Deprecated.Method attempts to find DataSchemaNode inside of provided Schema Context and Yang Module accordingly to Non-conditional Revision Aware XPath. The specified Module MUST be present in Schema Context otherwise the operation would fail and returnnull
.
The Revision Aware XPath MUST be specified WITHOUT the conditional statement (i.e. without [cond]) in path, because in this state the Schema Context is completely unaware of data state and will be not able to properly resolve XPath. If the XPath contains condition the method will return IllegalArgumentException.
If the Revision Aware XPath is correct and desired Data Schema Node is present in Yang module or in depending module in Schema Context the method will return specified Data Schema Node, otherwise the operation will fail and method will returnnull
.- Parameters:
context
- Schema Contextmodule
- Yang ModulenonCondXPath
- Non Conditional Revision Aware XPath- Returns:
- 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
-
findDataTreeSchemaNode
@Beta public static SchemaNode findDataTreeSchemaNode(SchemaContext ctx, QNameModule localModule, YangLocationPath absPath)
-
findDataTreeSchemaNode
@Beta public static SchemaNode findDataTreeSchemaNode(SchemaContext ctx, QNameModule localModule, PathExpression absPath)
-
findDataSchemaNodeForRelativeXPath
public static SchemaNode findDataSchemaNodeForRelativeXPath(SchemaContext context, Module module, SchemaNode actualSchemaNode, PathExpression relativeXPath)
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 returnnull
.
The relative Revision Aware XPath MUST be specified WITHOUT the conditional statement (i.e. without [cond]) in path, because in this state the Schema Context is completely unaware of data state and will be not able to properly resolve XPath. If the XPath contains condition the method will return IllegalArgumentException.
The Actual Schema Node MUST be specified correctly because from this Schema Node will search starts. If the Actual Schema Node is not correct the operation will simply fail, because it will be unable to find desired DataSchemaNode.
If the Revision Aware XPath doesn't have flagisAbsolute == false
the method will throw IllegalArgumentException.
If the relative Revision Aware XPath is correct and desired Data Schema Node is present in Yang module or in depending module in Schema Context the method will return specified Data Schema Node, otherwise the operation will fail and method will returnnull
.- Parameters:
context
- Schema Contextmodule
- Yang ModuleactualSchemaNode
- Actual Schema NoderelativeXPath
- Relative Non Conditional Revision Aware XPath- Returns:
- 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
-
findParentModule
public static Module findParentModule(SchemaContext context, SchemaNode schemaNode)
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 returnnull
.- Parameters:
context
- Schema ContextschemaNode
- Schema Node- Returns:
- 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
-
findNodeInSchemaContext
public static SchemaNode findNodeInSchemaContext(SchemaContext context, Iterable<QName> path)
-
getNotificationSchema
@Beta public static @Nullable NotificationDefinition getNotificationSchema(@NonNull SchemaContext schema, @NonNull SchemaPath path)
Returns NotificationDefinition from Schema Context.- Parameters:
schema
- SchemaContext in which lookup should be performed.path
- Schema Path of notification- Returns:
- Notification schema or null, if notification is not present in schema context.
-
getRpcDataSchema
@Beta public static @Nullable ContainerSchemaNode getRpcDataSchema(@NonNull SchemaContext schema, @NonNull SchemaPath path)
Returns RPC Input or Output Data container from RPC definition.- Parameters:
schema
- SchemaContext in which lookup should be performed.path
- Schema path of RPC input/output data container- Returns:
- Notification schema or null, if notification is not present in schema context.
-
getConstituentModuleIdentifiers
public static Set<SourceIdentifier> getConstituentModuleIdentifiers(SchemaContext context)
Extract the identifiers of all modules and submodules which were used to create a particular SchemaContext.- Parameters:
context
- SchemaContext to be examined- Returns:
- Set of ModuleIdentifiers.
-
getBaseTypeForLeafRef
public static TypeDefinition<?> getBaseTypeForLeafRef(LeafrefTypeDefinition typeDefinition, SchemaContext schemaContext, SchemaNode schema)
Extracts the base type of node on which schema node points to. If target node is again of type LeafrefTypeDefinition, methods will be call recursively until it reach concrete type definition.- Parameters:
typeDefinition
- type of node which will be extractedschemaContext
- Schema Contextschema
- Schema Node- Returns:
- recursively found type definition this leafref is pointing to or null if the xpath is incorrect (null is there to preserve backwards compatibility)
-
getBaseTypeForLeafRef
public static TypeDefinition<?> getBaseTypeForLeafRef(LeafrefTypeDefinition typeDefinition, SchemaContext schemaContext, QName qname)
Returns base type fortypeDefinition
which belongs to module specified viaqname
. This handle the case when leafref type isn't specified as type substatement of leaf or leaf-list but is defined in other module as typedef which is then imported to referenced module.Because
typeDefinition
is definied via typedef statement, only absolute path is meaningful.
-
-