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 | Field and Description |
---|---|
protected Iterable<InstanceIdentifier.PathArgument> |
pathArguments |
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) |
InstanceIdentifier.InstanceIdentifierBuilder<T> |
builder()
Create a builder rooted at this key.
|
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.
|
static <T extends DataObject> |
builder(InstanceIdentifier<T> base)
Deprecated.
Use
builder() instead. |
<N extends ChildOf<? super T>> |
child(Class<N> container) |
<N extends Identifiable<K> & ChildOf<? super T>,K extends Identifier<N>> |
child(Class<N> listItem,
K listKey) |
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.
|
<N extends Identifiable<K> & DataObject,K extends Identifier<N>> |
firstKeyOf(Class<N> listItem,
Class<K> listKey)
Deprecated.
Use
firstKeyOf(Class) instead. |
List<InstanceIdentifier.PathArgument> |
getPath()
Deprecated.
Use
getPathArguments() instead. |
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() |
protected final transient Iterable<InstanceIdentifier.PathArgument> pathArguments
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 type@Deprecated public final <N extends Identifiable<K> & DataObject,K extends Identifier<N>> K firstKeyOf(Class<N> listItem, Class<K> listKey)
firstKeyOf(Class)
instead.listItem
- component typelistKey
- component key 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)
public final <N extends Identifiable<K> & ChildOf<? super T>,K extends Identifier<N>> KeyedInstanceIdentifier<N,K> child(Class<N> listItem, K listKey)
public final <N extends DataObject & Augmentation<? super T>> InstanceIdentifier<N> augmentation(Class<N> container)
@Deprecated public final List<InstanceIdentifier.PathArgument> getPath()
getPathArguments()
instead.public InstanceIdentifier.InstanceIdentifierBuilder<T> builder()
@Deprecated public static <T extends DataObject> InstanceIdentifier.InstanceIdentifierBuilder<T> builder(InstanceIdentifier<T> base)
builder()
instead.public static <T extends ChildOf<? extends DataRoot>> InstanceIdentifier.InstanceIdentifierBuilder<T> builder(Class<T> container)
T
- Type of the containercontainer
- Base containerpublic 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
public 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.