Class YangInstanceIdentifier
java.lang.Object
org.opendaylight.yangtools.concepts.AbstractHierarchicalIdentifier<YangInstanceIdentifier,YangInstanceIdentifier.PathArgument>
org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier
- All Implemented Interfaces:
Serializable
,HierarchicalIdentifier<YangInstanceIdentifier>
,Identifier
,Immutable
public abstract sealed class YangInstanceIdentifier
extends AbstractHierarchicalIdentifier<YangInstanceIdentifier,YangInstanceIdentifier.PathArgument>
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
node
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic 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 class
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()
.static @NonNull YangInstanceIdentifier
create
(Iterable<? extends YangInstanceIdentifier.PathArgument> path) Deprecated, for removal: This API element is subject to removal in a future version.static @NonNull YangInstanceIdentifier
create
(YangInstanceIdentifier.PathArgument pathArgument) Deprecated, for removal: This API element is subject to removal in a future version.Useof(NodeIdentifier)
instead.static @NonNull YangInstanceIdentifier
Deprecated, for removal: This API element is subject to removal in a future version.Useof(PathArgument...)
instead.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 final @NonNull YangInstanceIdentifier
empty()
Deprecated, for removal: This API element is subject to removal in a future version.Useof()
instead.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.protected final Iterator<YangInstanceIdentifier.PathArgument>
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 final @NonNull YangInstanceIdentifier
of()
Return an emptyYangInstanceIdentifier
.static final @NonNull YangInstanceIdentifier
Returns a new InstanceIdentifier composed of suppliedYangInstanceIdentifier.PathArgument
s.static final @NonNull YangInstanceIdentifier
of
(Iterable<? extends YangInstanceIdentifier.PathArgument> path) Returns a new InstanceIdentifier composed of suppliedYangInstanceIdentifier.PathArgument
s.static final @NonNull YangInstanceIdentifier
of
(Collection<? extends YangInstanceIdentifier.PathArgument> path) Returns a new InstanceIdentifier composed of suppliedYangInstanceIdentifier.PathArgument
s.static final @NonNull YangInstanceIdentifier
Returns a newYangInstanceIdentifier
with only one path argument of typeYangInstanceIdentifier.NodeIdentifier
with suppliedQName
.static final @NonNull YangInstanceIdentifier
Returns a newYangInstanceIdentifier
with path arguments of typeYangInstanceIdentifier.NodeIdentifier
with suppliedQName
s.static final @NonNull YangInstanceIdentifier
Returns a new InstanceIdentifier with only one path argument of typeYangInstanceIdentifier.PathArgument
.static final @NonNull YangInstanceIdentifier
of
(YangInstanceIdentifier.PathArgument... path) Returns a new InstanceIdentifier composed of suppliedYangInstanceIdentifier.PathArgument
s.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()
protected final Object
Methods inherited from class org.opendaylight.yangtools.concepts.AbstractHierarchicalIdentifier
contains, throwNSE
-
Method Details
-
empty
@Deprecated(since="11.0.0", forRemoval=true) public static final @NonNull YangInstanceIdentifier empty()Deprecated, for removal: This API element is subject to removal in a future version.Useof()
instead.Return An emptyYangInstanceIdentifier
. It corresponds to the path of the conceptual root of the YANG namespace.- Returns:
- An empty YangInstanceIdentifier
-
of
Return an emptyYangInstanceIdentifier
. It corresponds to the path of the conceptual root of the YANG namespace.- Returns:
- An empty YangInstanceIdentifier
-
of
Returns a new InstanceIdentifier with only one path argument of typeYangInstanceIdentifier.PathArgument
.- Parameters:
name
- QName of first node identifier- Returns:
- A YangInstanceIdentifier
- Throws:
NullPointerException
- ifname
isnull
-
of
Returns a new InstanceIdentifier composed of suppliedYangInstanceIdentifier.PathArgument
s.- Parameters:
path
- Path arguments- Returns:
- A YangInstanceIdentifier
- Throws:
NullPointerException
- ifpath
or any of its components isnull
-
of
public static final @NonNull YangInstanceIdentifier of(ImmutableList<YangInstanceIdentifier.PathArgument> path) Returns a new InstanceIdentifier composed of suppliedYangInstanceIdentifier.PathArgument
s.- Parameters:
path
- Path arguments- Returns:
- A YangInstanceIdentifier
- Throws:
NullPointerException
- ifpath
isnull
-
of
public static final @NonNull YangInstanceIdentifier of(Collection<? extends YangInstanceIdentifier.PathArgument> path) Returns a new InstanceIdentifier composed of suppliedYangInstanceIdentifier.PathArgument
s.- Parameters:
path
- Path arguments- Returns:
- A YangInstanceIdentifier
- Throws:
NullPointerException
- ifpath
or any of its components isnull
-
of
public static final @NonNull YangInstanceIdentifier of(Iterable<? extends YangInstanceIdentifier.PathArgument> path) Returns a new InstanceIdentifier composed of suppliedYangInstanceIdentifier.PathArgument
s.- Parameters:
path
- Path arguments- Returns:
- A YangInstanceIdentifier
- Throws:
NullPointerException
- ifpath
or any of its components isnull
-
of
Returns a newYangInstanceIdentifier
with only one path argument of typeYangInstanceIdentifier.NodeIdentifier
with suppliedQName
. Note this is a convenience method aimed at test code. Production code should consider usingof(PathArgument)
instead.- Parameters:
name
- QName of firstYangInstanceIdentifier.NodeIdentifier
- Returns:
- A YangInstanceIdentifier
- Throws:
NullPointerException
- ifname
isnull
-
of
Returns a newYangInstanceIdentifier
with path arguments of typeYangInstanceIdentifier.NodeIdentifier
with suppliedQName
s. Note this is a convenience method aimed at test code. Production code should consider usingof(PathArgument...)
instead.- Parameters:
path
- QNames ofYangInstanceIdentifier.NodeIdentifier
s- Returns:
- A YangInstanceIdentifier
- Throws:
NullPointerException
- ifpath
or any of its components isnull
-
create
@Deprecated(since="11.0.0", forRemoval=true) public static @NonNull YangInstanceIdentifier create(YangInstanceIdentifier.PathArgument pathArgument) Deprecated, for removal: This API element is subject to removal in a future version.Useof(NodeIdentifier)
instead.Create a YangInstanceIdentifier composed of a singleYangInstanceIdentifier.PathArgument
.- Parameters:
pathArgument
- Path argument- Returns:
- A
YangInstanceIdentifier
- Throws:
NullPointerException
- ifpathArgument
is null
-
create
@Deprecated(since="11.0.0", forRemoval=true) public static @NonNull YangInstanceIdentifier create(YangInstanceIdentifier.PathArgument... path) Deprecated, for removal: This API element is subject to removal in a future version.Useof(PathArgument...)
instead.Create a YangInstanceIdentifier composed of specifiedYangInstanceIdentifier.PathArgument
s.- Parameters:
path
- Path arguments- Returns:
- A
YangInstanceIdentifier
- Throws:
NullPointerException
- ifpath
or any of its components isnull
-
create
@Deprecated(since="11.0.0", forRemoval=true) public static @NonNull YangInstanceIdentifier create(Iterable<? extends YangInstanceIdentifier.PathArgument> path) Deprecated, for removal: This API element is subject to removal in a future version.Useof(Iterable)
instead.Create a YangInstanceIdentifier composed of specifiedYangInstanceIdentifier.PathArgument
s.- Parameters:
path
- Path arguments- Returns:
- A
YangInstanceIdentifier
- Throws:
NullPointerException
- ifpath
or any of its components isnull
-
isEmpty
public abstract boolean isEmpty()Check if this instance identifier has empty path arguments, e.g. it is empty and corresponds toof()
.- 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 isof()
.
-
coerceParent
Return the conceptual parentYangInstanceIdentifier
, which has one item less ingetPathArguments()
.- Returns:
- Parent
YangInstanceIdentifier
- Throws:
VerifyException
- if this object isof()
.
-
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.
-
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
- Specified by:
equals
in classAbstractHierarchicalIdentifier<YangInstanceIdentifier,
YangInstanceIdentifier.PathArgument>
-
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.
-
itemIterator
- Specified by:
itemIterator
in classAbstractHierarchicalIdentifier<YangInstanceIdentifier,
YangInstanceIdentifier.PathArgument>
-
writeReplace
- Specified by:
writeReplace
in classAbstractHierarchicalIdentifier<YangInstanceIdentifier,
YangInstanceIdentifier.PathArgument>
-
toString
- Specified by:
toString
in interfaceIdentifier
- Specified by:
toString
in classAbstractHierarchicalIdentifier<YangInstanceIdentifier,
YangInstanceIdentifier.PathArgument>
-
hashCode
public final int hashCode()- Specified by:
hashCode
in interfaceIdentifier
- Specified by:
hashCode
in classAbstractHierarchicalIdentifier<YangInstanceIdentifier,
YangInstanceIdentifier.PathArgument>
-
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.
-
of(Iterable)
instead.