...
Code Block | ||
---|---|---|
| ||
File : TunnelType.java public abstract class TunnelType { } |
Identityref
Overview
The leafref type is used to reference a particular leaf instance in the data tree. Path statement must be present for leafref type. The path under leafref must refer to existing leaf or leaf-list. The leaf or leaf-list with leafref will use the instance of the referred leaf or leaf-list.
If leafref comes under grouping and typedef, it will be resolved where it is used. It will not be resolved where it is defined.
Java mapping
The leaf or leaf-list with type leafref, will copy the type of referred leaf or leaf-list, during java file generation.
Example
Code Block | ||
---|---|---|
| ||
File : ietf-network.yang
module ietf-network {
yang-version 1;
namespace "urn:ietf:params:xml:ns:yang:ietf-network";
prefix nd;
container networks {
description
"Serves as top-level container for a list of
networks.";
leaf network-id {
type uint8;
description
"Identifies a network.";
}
}
container network-id {
description
"Serves as top-level container for a list of
networks.";
leaf network-id {
type leafref {
path "/nd:networks/nd:network-id";
}
}
}
} |
Code Block | ||
---|---|---|
| ||
File : Networks.java
public interface Networks {
short networkId();
interface NetworksBuilder {
short networkId();
NetworksBuilder networkId(short networkId);
Networks build();
}
}
File : NetworkId.java
public interface NetworkId {
short networkRef();
interface NetworkIdBuilder {
short networkRef();
NetworkIdBuilder networkRef(short networkRef);
NetworkId build();
}
} |
Golden Eye Demo
Link: https://www.youtube.com/watch?v=ipbu0x0LcDk
...