Class SchemaUtils
- java.lang.Object
-
- org.opendaylight.yangtools.yang.data.impl.schema.SchemaUtils
-
public final class SchemaUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
belongsToCaseAugment(CaseSchemaNode caseNode, YangInstanceIdentifier.AugmentationIdentifier childToProcess)
static Optional<CaseSchemaNode>
detectCase(ChoiceSchemaNode schema, DataContainerChild<?,?> child)
static Collection<SchemaNode>
findChildSchemaNodesByQName(SchemaNode node, QName qname)
Find child schema node identified by its QName within a provided schema node.static AugmentationSchemaNode
findCorrespondingAugment(DataSchemaNode parent, DataSchemaNode child)
Tries to find inparent
which is dealed as augmentation target node with QName aschild
.static @Nullable SchemaNode
findDataChildSchemaByQName(SchemaNode node, QName qname)
Find child data schema node identified by its QName within a provided schema node.static SchemaNode
findDataParentSchemaOnPath(SchemaContext schemaContext, SchemaPath path)
Finds schema node for given path in schema context.static Optional<DataSchemaNode>
findFirstSchema(QName qname, Iterable<DataSchemaNode> dataSchemaNode)
Find the first schema with specified QName.static Collection<SchemaNode>
findParentSchemaNodesOnPath(SchemaContext schemaContext, SchemaPath path)
Finds schema node for given path in schema context.static AugmentationSchemaNode
findSchemaForAugment(AugmentationTarget schema, Set<QName> qnames)
static AugmentationSchemaNode
findSchemaForAugment(ChoiceSchemaNode schema, Set<QName> qnames)
static DataSchemaNode
findSchemaForChild(ChoiceSchemaNode schema, QName childPartialQName)
static DataSchemaNode
findSchemaForChild(DataNodeContainer schema, QName qname)
Find child schema node identified by its QName within a provided schema node.static @Nullable DataSchemaNode
findSchemaForChild(DataNodeContainer schema, QName qname, boolean strictMode)
static DataSchemaNode
findSchemaForChild(DataNodeContainer schema, QName qname, Iterable<DataSchemaNode> childNodes)
static Set<QName>
getChildNodesRecursive(DataNodeContainer nodeContainer)
Recursively list all child nodes.static Set<DataSchemaNode>
getRealSchemasForAugment(AugmentationTarget targetSchema, AugmentationSchemaNode augmentSchema)
Retrieves real schemas for augmented child node.static Set<DataSchemaNode>
getRealSchemasForAugment(DataNodeContainer targetSchema, AugmentationSchemaNode augmentSchema)
static Map<QName,AugmentationSchemaNode>
mapChildElementsFromAugments(AugmentationTarget schema)
Recursively find all child nodes that come from augmentations.static Map<QName,ChoiceSchemaNode>
mapChildElementsFromChoices(DataNodeContainer schema)
Recursively find all child nodes that come from choices.
-
-
-
Method Detail
-
findFirstSchema
public static Optional<DataSchemaNode> findFirstSchema(QName qname, Iterable<DataSchemaNode> dataSchemaNode)
Find the first schema with specified QName.- Parameters:
qname
- schema node to finddataSchemaNode
- Iterable of schemaNodes to look through- Returns:
- schema node with newest revision or absent if no schema node with matching qname is found
-
findSchemaForChild
public static DataSchemaNode findSchemaForChild(DataNodeContainer schema, QName qname)
Find child schema node identified by its QName within a provided schema node.- Parameters:
schema
- schema for parent node - search rootqname
- qname(with or without a revision) of a child node to be found in the parent schema- Returns:
- found schema node
- Throws:
IllegalStateException
- if the child was not found in parent schema node
-
findSchemaForChild
public static @Nullable DataSchemaNode findSchemaForChild(DataNodeContainer schema, QName qname, boolean strictMode)
-
findSchemaForChild
public static DataSchemaNode findSchemaForChild(DataNodeContainer schema, QName qname, Iterable<DataSchemaNode> childNodes)
-
findSchemaForChild
public static DataSchemaNode findSchemaForChild(ChoiceSchemaNode schema, QName childPartialQName)
-
findSchemaForAugment
public static AugmentationSchemaNode findSchemaForAugment(AugmentationTarget schema, Set<QName> qnames)
-
findSchemaForAugment
public static AugmentationSchemaNode findSchemaForAugment(ChoiceSchemaNode schema, Set<QName> qnames)
-
mapChildElementsFromChoices
public static Map<QName,ChoiceSchemaNode> mapChildElementsFromChoices(DataNodeContainer schema)
Recursively find all child nodes that come from choices.- Parameters:
schema
- schema- Returns:
- Map with all child nodes, to their most top augmentation
-
mapChildElementsFromAugments
public static Map<QName,AugmentationSchemaNode> mapChildElementsFromAugments(AugmentationTarget schema)
Recursively find all child nodes that come from augmentations.- Parameters:
schema
- schema- Returns:
- Map with all child nodes, to their most top augmentation
-
getChildNodesRecursive
public static Set<QName> getChildNodesRecursive(DataNodeContainer nodeContainer)
Recursively list all child nodes. In case of choice, augment and cases, step in.- Parameters:
nodeContainer
- node container- Returns:
- set of QNames
-
getRealSchemasForAugment
public static Set<DataSchemaNode> getRealSchemasForAugment(AugmentationTarget targetSchema, AugmentationSchemaNode augmentSchema)
Retrieves real schemas for augmented child node.Schema of the same child node from augment, and directly from target is not the same. Schema of child node from augment is incomplete, therefore its useless for XML/NormalizedNode translation.
- Parameters:
targetSchema
- target schemaaugmentSchema
- augment schema- Returns:
- set of nodes
-
getRealSchemasForAugment
public static Set<DataSchemaNode> getRealSchemasForAugment(DataNodeContainer targetSchema, AugmentationSchemaNode augmentSchema)
-
detectCase
public static Optional<CaseSchemaNode> detectCase(ChoiceSchemaNode schema, DataContainerChild<?,?> child)
-
belongsToCaseAugment
public static boolean belongsToCaseAugment(CaseSchemaNode caseNode, YangInstanceIdentifier.AugmentationIdentifier childToProcess)
-
findCorrespondingAugment
public static AugmentationSchemaNode findCorrespondingAugment(DataSchemaNode parent, DataSchemaNode child)
Tries to find inparent
which is dealed as augmentation target node with QName aschild
. If such node is found then it is returned, else null.- Parameters:
parent
- parent nodechild
- child node- Returns:
- augmentation schema
-
findDataParentSchemaOnPath
public static SchemaNode findDataParentSchemaOnPath(SchemaContext schemaContext, SchemaPath path)
Finds schema node for given path in schema context. This method performs lookup in the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas, and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.- Parameters:
schemaContext
- schema contextpath
- path- Returns:
- schema node on path
-
findDataChildSchemaByQName
public static @Nullable SchemaNode findDataChildSchemaByQName(SchemaNode node, QName qname)
Find child data schema node identified by its QName within a provided schema node. This method performs lookup in the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas and anyxmls according to RFC6050/RFC7950 section 6.2.1.- Parameters:
node
- schema nodeqname
- QName- Returns:
- data child schema node
- Throws:
IllegalArgumentException
- if the schema node does not allow children
-
findParentSchemaNodesOnPath
public static Collection<SchemaNode> findParentSchemaNodesOnPath(SchemaContext schemaContext, SchemaPath path)
Finds schema node for given path in schema context. This method performs lookup in both the namespace of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas and anyxmls according to Rfc6050/Rfc7950 section 6.2.1.This method returns collection of SchemaNodes, because name conflicts can occur between the namespace of groupings and namespace of data nodes. This method finds and collects all schema nodes that matches supplied SchemaPath and returns them all as collection of schema nodes.
- Parameters:
schemaContext
- schema contextpath
- path- Returns:
- collection of schema nodes on path
-
findChildSchemaNodesByQName
public static Collection<SchemaNode> findChildSchemaNodesByQName(SchemaNode node, QName qname)
Find child schema node identified by its QName within a provided schema node. This method performs lookup in both the namespace of groupings and the namespace of all leafs, leaf-lists, lists, containers, choices, rpcs, actions, notifications, anydatas and anyxmls according to RFC6050/RFC7950 section 6.2.1.This method returns collection of SchemaNodes, because name conflicts can occur between the namespace of groupings and namespace of data nodes. This method finds and collects all schema nodes with supplied QName and returns them all as collection of schema nodes.
- Parameters:
node
- schema nodeqname
- QName- Returns:
- collection of child schema nodes
- Throws:
IllegalArgumentException
- if the schema node does not allow children
-
-