public class InstanceIdentifier<T extends DataObject> extends Object implements org.opendaylight.yangtools.concepts.Path<InstanceIdentifier<? extends DataObject>>, org.opendaylight.yangtools.concepts.Immutable, Serializable
For Example let's say you were trying to refer to a node in inventory which was modeled in YANG as follows,
module opendaylight-inventory { .... container nodes { list node { key "id"; ext:context-instance "node-context"; uses node; } } }
You can create an instance identifier as follows to get to a node with id "openflow:1": InstanceIdentifierBuilder.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1")).build();
This would be the same as using a path like so, "/nodes/node/openflow:1" to refer to the openflow:1 node
Modifier and Type | Class and Description |
---|---|
static class |
InstanceIdentifier.IdentifiableItem<I extends Identifiable<T> & DataObject,T extends Identifier<I>>
An IdentifiableItem represents a object that is usually present in a collection and can be identified uniquely
by a key.
|
static interface |
InstanceIdentifier.InstanceIdentifierBuilder<T extends DataObject> |
static class |
InstanceIdentifier.Item<T extends DataObject>
An Item represents an object that probably is only one of it's kind.
|
static interface |
InstanceIdentifier.PathArgument
Path argument of
InstanceIdentifier . |
Modifier and Type | Method and Description |
---|---|
protected com.google.common.base.MoreObjects.ToStringHelper |
addToStringAttributes(com.google.common.base.MoreObjects.ToStringHelper toStringHelper)
Add class-specific toString attributes.
|
<N extends DataObject & Augmentation<? super T>> |
augmentation(Class<N> container)
Create an InstanceIdentifier for a child augmentation.
|
InstanceIdentifier.InstanceIdentifierBuilder<T> |
builder()
Create a builder rooted at this key.
|
static <C extends ChoiceIn<? extends DataRoot> & DataObject,N extends Identifiable<K> & ChildOf<? super C>,K extends Identifier<N>> |
builder(Class<C> caze,
Class<N> listItem,
K listKey)
Create an InstanceIdentifierBuilder for a specific type of InstanceIdentifier which represents an
InstanceIdentifier.IdentifiableItem in a grouping used in the case statement. |
static <C extends ChoiceIn<? extends DataRoot> & DataObject,T extends ChildOf<? super C>> |
builder(Class<C> caze,
Class<T> container)
Create an InstanceIdentifierBuilder for a specific type of InstanceIdentifier as specified by container in
a
grouping used in the case statement. |
static <N extends Identifiable<K> & ChildOf<? extends DataRoot>,K extends Identifier<N>> |
builder(Class<N> listItem,
K listKey)
Create an InstanceIdentifierBuilder for a specific type of InstanceIdentifier which represents an
InstanceIdentifier.IdentifiableItem . |
static <T extends ChildOf<? extends DataRoot>> |
builder(Class<T> container)
Create an InstanceIdentifierBuilder for a specific type of InstanceIdentifier as specified by container.
|
<C extends ChoiceIn<? super T> & DataObject,N extends ChildOf<? super C>> |
child(Class<C> caze,
Class<N> container)
Create an InstanceIdentifier for a child container.
|
<C extends ChoiceIn<? super T> & DataObject,K extends Identifier<N>,N extends Identifiable<K> & ChildOf<? super C>> |
child(Class<C> caze,
Class<N> listItem,
K listKey)
Create an InstanceIdentifier for a child list item.
|
<N extends ChildOf<? super T>> |
child(Class<N> container)
Create an InstanceIdentifier for a child container.
|
<N extends Identifiable<K> & ChildOf<? super T>,K extends Identifier<N>> |
child(Class<N> listItem,
K listKey)
Create an InstanceIdentifier for a child list item.
|
boolean |
contains(InstanceIdentifier<? extends DataObject> other)
Check whether an identifier is contained in this identifier.
|
boolean |
containsWildcarded(InstanceIdentifier<?> other)
Check whether this instance identifier contains the other identifier after wildcard expansion.
|
static <T extends DataObject> |
create(Class<T> type)
Create an instance identifier for a very specific object type.
|
static InstanceIdentifier<?> |
create(Iterable<? extends InstanceIdentifier.PathArgument> pathArguments)
Create an instance identifier for a very specific object type.
|
boolean |
equals(Object obj) |
protected boolean |
fastNonEqual(InstanceIdentifier<?> other)
Perform class-specific fast checks for non-equality.
|
<I extends DataObject> |
firstIdentifierOf(Class<I> type)
Return an instance identifier trimmed at the first occurrence of a specific component type.
|
<N extends Identifiable<K> & DataObject,K extends Identifier<N>> |
firstKeyOf(Class<N> listItem)
Return the key associated with the first component of specified type in
an identifier.
|
Iterable<InstanceIdentifier.PathArgument> |
getPathArguments()
Return the path argument chain which makes up this instance identifier.
|
Class<T> |
getTargetType()
Return the type of data which this InstanceIdentifier identifies.
|
int |
hashCode() |
boolean |
isWildcarded()
Check whether an instance identifier contains any wildcards.
|
static <N extends Identifiable<K> & DataObject,K extends Identifier<N>> |
keyOf(InstanceIdentifier<N> id)
Return the key associated with the last component of the specified identifier.
|
String |
toString() |
public final Class<T> getTargetType()
public final Iterable<InstanceIdentifier.PathArgument> getPathArguments()
public final boolean isWildcarded()
protected boolean fastNonEqual(InstanceIdentifier<?> other)
other
- The other identifier, guaranteed to be the same classprotected com.google.common.base.MoreObjects.ToStringHelper addToStringAttributes(com.google.common.base.MoreObjects.ToStringHelper toStringHelper)
toStringHelper
- ToStringHelper instancepublic final <I extends DataObject> InstanceIdentifier<I> firstIdentifierOf(Class<I> type)
For example let's say an instance identifier was built like so,
identifier = InstanceIdentifierBuilder.builder(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1")).build();
And you wanted to obtain the Instance identifier which represented Nodes you would do it like so,
identifier.firstIdentifierOf(Nodes.class)
type
- component typepublic final <N extends Identifiable<K> & DataObject,K extends Identifier<N>> K firstKeyOf(Class<N> listItem)
listItem
- component typepublic final boolean contains(InstanceIdentifier<? extends DataObject> other)
The contains method checks if the other identifier is fully contained within the current identifier. It does this by looking at only the types of the path arguments and not by comparing the path arguments themselves.
To illustrate here is an example which explains the working of this API. Let's say you have two instance
identifiers as follows:
this = /nodes/node/openflow:1
other = /nodes/node/openflow:2
then this.contains(other) will return false.
contains
in interface org.opendaylight.yangtools.concepts.Path<InstanceIdentifier<? extends DataObject>>
other
- Potentially-container instance identifierpublic final boolean containsWildcarded(InstanceIdentifier<?> other)
contains(InstanceIdentifier)
, with the exception that a wildcards are assumed to match the their
non-wildcarded PathArgument counterpart.other
- Identifier which should be checked for inclusion.public final <N extends ChildOf<? super T>> InstanceIdentifier<N> child(Class<N> container)
builder().child(container).build()
.N
- Container typecontainer
- Container to appendNullPointerException
- if container
is nullpublic final <N extends Identifiable<K> & ChildOf<? super T>,K extends Identifier<N>> KeyedInstanceIdentifier<N,K> child(Class<N> listItem, K listKey)
builder().child(listItem, listKey).build()
.N
- List typeK
- Key typelistItem
- List to appendlistKey
- List keyNullPointerException
- if any argument is nullpublic final <C extends ChoiceIn<? super T> & DataObject,N extends ChildOf<? super C>> InstanceIdentifier<N> child(Class<C> caze, Class<N> container)
builder().child(caze, container).build()
.C
- Case typeN
- Container typecaze
- Choice case classcontainer
- Container to appendNullPointerException
- if any argument is nullpublic final <C extends ChoiceIn<? super T> & DataObject,K extends Identifier<N>,N extends Identifiable<K> & ChildOf<? super C>> KeyedInstanceIdentifier<N,K> child(Class<C> caze, Class<N> listItem, K listKey)
builder().child(caze, listItem, listKey).build()
.C
- Case typeN
- List typeK
- Key typecaze
- Choice case classlistItem
- List to appendlistKey
- List keyNullPointerException
- if any argument is nullpublic final <N extends DataObject & Augmentation<? super T>> InstanceIdentifier<N> augmentation(Class<N> container)
builder().augmentation(container).build()
.N
- Container typecontainer
- Container to appendNullPointerException
- if container
is nullpublic InstanceIdentifier.InstanceIdentifierBuilder<T> builder()
public static <T extends ChildOf<? extends DataRoot>> InstanceIdentifier.InstanceIdentifierBuilder<T> builder(Class<T> container)
T
- Type of the containercontainer
- Base containerInstanceIdentifier.InstanceIdentifierBuilder
NullPointerException
- if container
is nullpublic static <C extends ChoiceIn<? extends DataRoot> & DataObject,T extends ChildOf<? super C>> InstanceIdentifier.InstanceIdentifierBuilder<T> builder(Class<C> caze, Class<T> container)
grouping
used in the case
statement.C
- Case typeT
- Type of the containercaze
- Choice case classcontainer
- Base containerInstanceIdentifier.InstanceIdentifierBuilder
NullPointerException
- if any argument is nullpublic static <N extends Identifiable<K> & ChildOf<? extends DataRoot>,K extends Identifier<N>> InstanceIdentifier.InstanceIdentifierBuilder<N> builder(Class<N> listItem, K listKey)
InstanceIdentifier.IdentifiableItem
.N
- List typeK
- List keylistItem
- list item classlistKey
- key valueInstanceIdentifier.InstanceIdentifierBuilder
NullPointerException
- if any argument is nullpublic static <C extends ChoiceIn<? extends DataRoot> & DataObject,N extends Identifiable<K> & ChildOf<? super C>,K extends Identifier<N>> InstanceIdentifier.InstanceIdentifierBuilder<N> builder(Class<C> caze, Class<N> listItem, K listKey)
InstanceIdentifier.IdentifiableItem
in a grouping
used in the case
statement.C
- Case typeN
- List typeK
- List keycaze
- Choice case classlistItem
- list item classlistKey
- key valueInstanceIdentifier.InstanceIdentifierBuilder
NullPointerException
- if any argument is nullpublic static InstanceIdentifier<?> create(Iterable<? extends InstanceIdentifier.PathArgument> pathArguments)
Example:
List<PathArgument> path = Arrays.asList(new Item(Nodes.class)) new InstanceIdentifier(path);
pathArguments
- The path to a specific node in the data treeIllegalArgumentException
- if pathArguments is empty or
contains a null element.public static <T extends DataObject> InstanceIdentifier<T> create(Class<T> type)
For example
new InstanceIdentifier(Nodes.class)would create an InstanceIdentifier for an object of type Nodes
type
- The type of the object which this instance identifier representspublic static <N extends Identifiable<K> & DataObject,K extends Identifier<N>> K keyOf(InstanceIdentifier<N> id)
id
- instance identifierIllegalArgumentException
- if the supplied identifier type cannot have a key.NullPointerException
- if id is null.Copyright © 2019 OpenDaylight. All rights reserved.