Class SchemaInferenceStack
- java.lang.Object
-
- org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack
-
- All Implemented Interfaces:
Mutable
,MutationBehaviour<Mutable>
,EffectiveModelContextProvider
@Beta public final class SchemaInferenceStack extends Object implements Mutable, EffectiveModelContextProvider
A state tracking utility for walkingEffectiveModelContext
's contents along schema/grouping namespaces. This is conceptually a stack, trackingEffectiveStatement
s encountered along traversal.This is meant to be a replacement concept for the use of
SchemaPath
in various places, notably inSchemaContextUtil
methods.This class is designed for single-threaded uses and does not make any guarantees around concurrent access.
-
-
Constructor Summary
Constructors Constructor Description SchemaInferenceStack(EffectiveModelContext effectiveModel)
Create a new empty stack backed by an effective model.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
clear()
Reset this stack to empty state.@NonNull SchemaInferenceStack
copy()
Create a deep copy of this object.@NonNull ModuleEffectiveStatement
currentModule()
Return current module the stack has entered.@NonNull EffectiveStatement<QName,?>
currentStatement()
Return the statement at the top of the stack.@NonNull GroupingEffectiveStatement
enterGrouping(QName nodeIdentifier)
Lookup a grouping by its node identifier and push it to the stack.@NonNull EffectiveStatement<QName,?>
enterSchemaTree(QName nodeIdentifier)
Lookup a schema tree child by its node identifier and push it to the stack.@NonNull EffectiveStatement<QName,?>
exit()
Pop the current statement from the stack.EffectiveModelContext
getEffectiveModelContext()
Return theEffectiveModelContext
attached to this object.boolean
inInstantiatedContext()
Check if the stack is in instantiated context.boolean
isEmpty()
Check if this stack is empty.@NonNull SchemaNodeIdentifier.Absolute
toSchemaNodeIdentifier()
Convert current state into an absolute schema node identifier.@NonNull SchemaPath
toSchemaPath()
Deprecated.This method is meant only for interoperation with SchemaPath-based APIs.String
toString()
-
-
-
Constructor Detail
-
SchemaInferenceStack
public SchemaInferenceStack(EffectiveModelContext effectiveModel)
Create a new empty stack backed by an effective model.- Parameters:
effectiveModel
- EffectiveModelContext to which this stack is attached- Throws:
NullPointerException
-effectiveModel
is null
-
-
Method Detail
-
getEffectiveModelContext
public EffectiveModelContext getEffectiveModelContext()
Description copied from interface:EffectiveModelContextProvider
Return theEffectiveModelContext
attached to this object.- Specified by:
getEffectiveModelContext
in interfaceEffectiveModelContextProvider
- Returns:
- An EffectiveModelContext instance.
-
copy
public @NonNull SchemaInferenceStack copy()
Create a deep copy of this object.- Returns:
- An isolated copy of this object
-
isEmpty
public boolean isEmpty()
Check if this stack is empty.- Returns:
- True if this stack has not entered any node.
-
currentStatement
public @NonNull EffectiveStatement<QName,?> currentStatement()
Return the statement at the top of the stack.- Returns:
- Top statement
- Throws:
IllegalStateException
- if the stack is empty
-
currentModule
public @NonNull ModuleEffectiveStatement currentModule()
Return current module the stack has entered.- Returns:
- Current module
- Throws:
IllegalStateException
- if the stack is empty
-
inInstantiatedContext
public boolean inInstantiatedContext()
Check if the stack is in instantiated context. This indicates the stack is non-empty and there is no grouping (or similar construct) present in the stack.- Returns:
- False if the stack is empty or contains a grouping, true otherwise.
-
clear
public void clear()
Reset this stack to empty state.
-
enterGrouping
public @NonNull GroupingEffectiveStatement enterGrouping(QName nodeIdentifier)
Lookup a grouping by its node identifier and push it to the stack.- Parameters:
nodeIdentifier
- Node identifier of the grouping to enter- Returns:
- Resolved grouping
- Throws:
NullPointerException
- ifnodeIdentifier
is nullIllegalArgumentException
- if the corresponding grouping cannot be found
-
enterSchemaTree
public @NonNull EffectiveStatement<QName,?> enterSchemaTree(QName nodeIdentifier)
Lookup a schema tree child by its node identifier and push it to the stack.- Parameters:
nodeIdentifier
- Node identifier of the schema tree child to enter- Returns:
- Resolved schema tree child
- Throws:
NullPointerException
- ifnodeIdentifier
is nullIllegalArgumentException
- if the corresponding grouping cannot be found
-
exit
public @NonNull EffectiveStatement<QName,?> exit()
Pop the current statement from the stack.- Returns:
- Previous statement
- Throws:
NoSuchElementException
- if this stack is empty
-
toSchemaNodeIdentifier
public @NonNull SchemaNodeIdentifier.Absolute toSchemaNodeIdentifier()
Convert current state into an absolute schema node identifier.- Returns:
- Absolute schema node identifier representing current state
- Throws:
IllegalStateException
- if current state is not instantiated
-
toSchemaPath
@Deprecated public @NonNull SchemaPath toSchemaPath()
Deprecated.This method is meant only for interoperation with SchemaPath-based APIs.Convert current state into a SchemaPath.- Returns:
- Absolute SchemaPath representing current state
- Throws:
IllegalStateException
- if current state is not instantiated
-
-