Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This is the kind of object (module) that gets created:

Image RemovedImage Added

Generated Java Object Structures per Yang concept

...

The Class DataSchemaNode can represent a Yang Leaf, List or Container

Main data types

The package org.opendaylight.yangtools.yang.model.util.type contains classes for all the possible data types including:

  • BaseBinaryType
  • BaseBitsType
  • BaseBooleanType
  • BaseDecimalType
  • BaseEnumerationType
  • BaseInt8Type
  • BaseInt16Type
  • BaseInt32Type
  • BaseInt64Type
  • BaseStringType
  • BaseUint8Type
  • BaseUint16Type
  • BaseUint32Type
  • BaseUint64Type

There are also some special data types such as:

  • BaseIdentityrefType
  • BaseInstanceIdentifierType
  • BaseLeafrefType
  • BaseUnionType


DescriptionYangJava Object ViewNotes

Datatypes and basic constraints

Basic String

leaf response-code {
  type string;
}

834px

Image Modified


Mandatory Basic String

leaf response-code {
  type string;
    mandatory "true";
}

Image Modified


Limited String leaf pnf-name {
  type string {
    length "0..256";
}

Image Modified

Specialized class to hold length limitation
typedef (String) with pattern

typedef dotted-quad {
  type string {
pattern
  '(([0-9] ...';
  }
}

leaf address {
   type dotted-quad;
   mandatory "true";
}

Image Modified


Limited unint64 leaf cid {
  type string {
  length "0..52";
}

Image Modified


boolean with default value

leaf blacklisted {
  type boolean;
  default 1;
}

Image Modified


Unique

Unique list server {
  key "name";
  unique "ip port";
  leaf name {
    type string;
  }
  leaf ip {
    type dotted-quad;
  }
  leaf port {
    type uint32;
  }}

Image Modified


Choice

Choicechoice transfer-method {
  leaf transfer-interval {
    type uint64 { range "15..2880"; }
    units minutes; }
  leaf transfer-on-commit {
  type empty;
  }}

Image Modified


Must

Must leaf ifType {
type enumeration {
enum ethernet;
enum atm;}}
leaf ifMTU {
type uint32;}
must "ifType != 'ethernet' or "
+ "(ifType = 'ethernet' and ifMTU = 1500)" {error-message 466px"An ethernet MTU must be 1500";}

Image Modified


When

When
leaf a {
    type boolean;
}
leaf b {
    type string;
    when "../a = 'true'";
}

Image Modified


Extension

Extension declaration extension store-state-ext {
argument duration;
description "An extension to enable state-storage for any attribute. Use duration to specify how long: nnn h|d|y";
}

Image Modified


Extension usage leaf attribute-with-temporal-storage {
  type string;
  cm-notify-api:store-state-ext "3 d"; // store state 3 days
}

Image Modified

extension is stored as 'UnknownNode' and refers back to the extension declaration

Augmentation


augment "server" {
  when "port = '8787'";
    leaf enable-debug {
      type boolean;
    }
}

Image Added