Class YangInstanceIdentifier
java.lang.Object
org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
- All Implemented Interfaces:
Serializable
,HierarchicalIdentifier<YangInstanceIdentifier>
,Identifier
,Immutable
public abstract sealed class YangInstanceIdentifier
extends Object
implements HierarchicalIdentifier<YangInstanceIdentifier>
Unique identifier of a particular node instance in the data tree.
Java representation of YANG Built-in type instance-identifier
, which conceptually is XPath expression
minimized to uniquely identify element in data tree which conforms to constraints maintained by YANG Model,
effectively this makes Instance Identifier a path to element in data tree.
Constraints put in YANG specification on instance-identifier allowed it to be effectively represented in Java and its evaluation does not require a full-blown XPath processor.
Path Arguments
Path to the node represented in instance identifier consists ofYangInstanceIdentifier.PathArgument
which carries necessary
information to uniquely identify node on particular level in the subtree.
YangInstanceIdentifier.NodeIdentifier
- Identifier of node, which has cardinality0..1
in particular subtree in data treeYangInstanceIdentifier.NodeIdentifierWithPredicates
- Identifier of node (list item), which has cardinality0..n
YangInstanceIdentifier.NodeWithValue
- Identifier of instanceleaf
node orleaf-list
nodeYangInstanceIdentifier.AugmentationIdentifier
- Identifier of instance ofaugmentation
node
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Composite path argument identifying aAugmentationNode
node in particular subtree.static interface
Fluent Builder of Instance Identifier instances.static final class
Simple path argument identifying aContainerNode
orLeafNode
leaf in particular subtree.static class
Composite path argument identifying aMapEntryNode
leaf overall data tree.static final class
Simple path argument identifying aLeafSetEntryNode
leaf overall data tree.static interface
Path argument / component of InstanceIdentifier. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull YangInstanceIdentifier.InstanceIdentifierBuilder
builder()
Returns new builder for InstanceIdentifier with empty path arguments.static @NonNull YangInstanceIdentifier.InstanceIdentifierBuilder
builder
(YangInstanceIdentifier origin) Returns new builder for InstanceIdentifier with path arguments copied from original instance identifier.abstract @NonNull YangInstanceIdentifier
Return the conceptual parentYangInstanceIdentifier
, which has one item less ingetPathArguments()
.final boolean
contains
(YangInstanceIdentifier other) Check if this identifier contains some other identifier.static @NonNull YangInstanceIdentifier
create
(Iterable<? extends YangInstanceIdentifier.PathArgument> path) static @NonNull YangInstanceIdentifier
create
(YangInstanceIdentifier.PathArgument pathArgument) static @NonNull YangInstanceIdentifier
static <T> @NonNull YangInstanceIdentifier
createReverse
(Deque<? extends T> stackTowardsRoot, Function<T, YangInstanceIdentifier.PathArgument> function) Create aYangInstanceIdentifier
by walking specified stack backwards and extracting path components from it.static @NonNull YangInstanceIdentifier
createReverse
(Deque<YangInstanceIdentifier.PathArgument> pathTowardsRoot) Create aYangInstanceIdentifier
by taking a snapshot of provided path and iterating it backwards.static @NonNull YangInstanceIdentifier
empty()
Return An emptyYangInstanceIdentifier
.final boolean
abstract @NonNull YangInstanceIdentifier
getAncestor
(int depth) Return the ancestorYangInstanceIdentifier
with a particular depth, e.g.abstract YangInstanceIdentifier.PathArgument
Returns the last PathArgument.abstract @Nullable YangInstanceIdentifier
Return the conceptual parentYangInstanceIdentifier
, which has one item less ingetPathArguments()
.abstract @NonNull List<YangInstanceIdentifier.PathArgument>
Returns an ordered iteration of path arguments.abstract @NonNull List<YangInstanceIdentifier.PathArgument>
Returns an iterable of path arguments in reverse order.final int
hashCode()
abstract boolean
isEmpty()
Check if this instance identifier has empty path arguments, e.g.final @NonNull YangInstanceIdentifier
Constructs a new Instance Identifier with newYangInstanceIdentifier.NodeIdentifier
added to the end of path arguments.final @NonNull YangInstanceIdentifier
Constructs a new Instance Identifier with newYangInstanceIdentifier.PathArgument
added to the end of path arguments.static @NonNull YangInstanceIdentifier
Returns a new InstanceIdentifier with only one path argument of typeYangInstanceIdentifier.NodeIdentifier
with supplied QName.relativeTo
(YangInstanceIdentifier ancestor) Get the relative path from an ancestor.abstract @NonNull YangInstanceIdentifier
Return an optimized version of this identifier, useful when the identifier will be used very frequently.final String
toString()
-
Method Details
-
empty
Return An emptyYangInstanceIdentifier
. It corresponds to the path of the conceptual root of the YANG namespace.- Returns:
- An empty YangInstanceIdentifier
-
isEmpty
public abstract boolean isEmpty()Check if this instance identifier has empty path arguments, e.g. it is empty and corresponds toempty()
.- Returns:
- True if this instance identifier is empty, false otherwise.
-
toOptimized
Return an optimized version of this identifier, useful when the identifier will be used very frequently.- Returns:
- A optimized equivalent instance.
-
getParent
Return the conceptual parentYangInstanceIdentifier
, which has one item less ingetPathArguments()
.- Returns:
- Parent
YangInstanceIdentifier
, or null if this object isempty()
.
-
coerceParent
Return the conceptual parentYangInstanceIdentifier
, which has one item less ingetPathArguments()
.- Returns:
- Parent
YangInstanceIdentifier
- Throws:
VerifyException
- if this object isempty()
.
-
getAncestor
Return the ancestorYangInstanceIdentifier
with a particular depth, e.g. number of path arguments.- Parameters:
depth
- Ancestor depth- Returns:
- Ancestor
YangInstanceIdentifier
- Throws:
IllegalArgumentException
- if the specified depth is negative or is greater than the depth of this object.
-
getPathArguments
Returns an ordered iteration of path arguments.- Returns:
- Immutable iteration of path arguments.
-
getReversePathArguments
Returns an iterable of path arguments in reverse order. This is useful when walking up a tree organized this way.- Returns:
- Immutable iterable of path arguments in reverse order.
-
getLastPathArgument
Returns the last PathArgument. This is equivalent of iterating to the last element of the iterable returned bygetPathArguments()
.- Returns:
- The last past argument, or null if there are no PathArguments.
-
create
public static @NonNull YangInstanceIdentifier create(Iterable<? extends YangInstanceIdentifier.PathArgument> path) -
create
public static @NonNull YangInstanceIdentifier create(YangInstanceIdentifier.PathArgument pathArgument) -
create
-
createReverse
public static @NonNull YangInstanceIdentifier createReverse(Deque<YangInstanceIdentifier.PathArgument> pathTowardsRoot) Create aYangInstanceIdentifier
by taking a snapshot of provided path and iterating it backwards.- Parameters:
pathTowardsRoot
- Path towards root- Returns:
- A
YangInstanceIdentifier
instance - Throws:
NullPointerException
- ifpathTowardsRoot
or any of its members is null
-
createReverse
public static <T> @NonNull YangInstanceIdentifier createReverse(Deque<? extends T> stackTowardsRoot, Function<T, YangInstanceIdentifier.PathArgument> function) Create aYangInstanceIdentifier
by walking specified stack backwards and extracting path components from it.- Parameters:
stackTowardsRoot
- Stack towards root,- Returns:
- A
YangInstanceIdentifier
instance - Throws:
NullPointerException
- ifpathTowardsRoot
is null
-
equals
- Specified by:
equals
in interfaceIdentifier
- Overrides:
equals
in classObject
-
node
Constructs a new Instance Identifier with newYangInstanceIdentifier.NodeIdentifier
added to the end of path arguments.- Parameters:
name
- QName ofYangInstanceIdentifier.NodeIdentifier
- Returns:
- Instance Identifier with additional path argument added to the end.
-
node
Constructs a new Instance Identifier with newYangInstanceIdentifier.PathArgument
added to the end of path arguments.- Parameters:
arg
- Path argument which should be added to the end- Returns:
- Instance Identifier with additional path argument added to the end.
-
relativeTo
Get the relative path from an ancestor. This method attempts to perform the reverse of concatenating a base (ancestor) and a path.- Parameters:
ancestor
- Ancestor against which the relative path should be calculated- Returns:
- This object's relative path from parent, or Optional.absent() if the specified parent is not in fact an ancestor of this object.
-
contains
Description copied from interface:HierarchicalIdentifier
Check if this identifier contains some other identifier. If we take HierarchicalIdentifier to be similar to aPath
, this is method is the equivalent ofother.startsWith(this)
.- Specified by:
contains
in interfaceHierarchicalIdentifier<YangInstanceIdentifier>
- Parameters:
other
- Other identifier, may not be null- Returns:
- True if this identifier contains the other identifier
-
toString
- Specified by:
toString
in interfaceIdentifier
- Overrides:
toString
in classObject
-
hashCode
public final int hashCode()- Specified by:
hashCode
in interfaceIdentifier
- Overrides:
hashCode
in classObject
-
of
Returns a new InstanceIdentifier with only one path argument of typeYangInstanceIdentifier.NodeIdentifier
with supplied QName.- Parameters:
name
- QName of first node identifier- Returns:
- Instance Identifier with only one path argument of type
YangInstanceIdentifier.NodeIdentifier
-
builder
Returns new builder for InstanceIdentifier with empty path arguments.- Returns:
- new builder for InstanceIdentifier with empty path arguments.
-
builder
public static @NonNull YangInstanceIdentifier.InstanceIdentifierBuilder builder(YangInstanceIdentifier origin) Returns new builder for InstanceIdentifier with path arguments copied from original instance identifier.- Parameters:
origin
- InstanceIdentifier from which path arguments are copied.- Returns:
- new builder for InstanceIdentifier with path arguments copied from original instance identifier.
-