This package's type hierarchy model generates a type which encapsulates the default value and units for leaves.
Java Binding specification is implemented in a way, where it needs to revert this process if the internal
declaration has not restricted the type further -- which is not something available via
TypeDefinition#getBaseType().
Here are the possible scenarios:
leaf foo {
type uint8 {
range 1..2;
}
}
The leaf type's schema path does not match the schema path of the leaf. We do NOT want to strip it, as
we need to generate an inner class to hold the restrictions.
leaf foo {
type uint8 {
range 1..2;
}
default 1;
}
The leaf type's schema path will match the schema path of the leaf. We do NOT want to strip it, as we need
to generate an inner class to hold the restrictions.
leaf foo {
type uint8;
default 1;
}
The leaf type's schema path will match the schema path of the leaf. We DO want to strip it, as we will deal
with the default value ourselves.
leaf foo {
type uint8;
}
The leaf type's schema path will not match the schema path of the leaf. We do NOT want to strip it.
The situation is different for types which do not have a default instantiation in YANG: leafref, enumeration,
identityref, decimal64, bits and union. If these types are defined within this leaf's statement, a base type
will be instantiated. If the leaf defines a default statement, this base type will be visible via getBaseType().
leaf foo {
type decimal64 {
fraction-digits 2;
}
}
The leaf type's schema path will not match the schema path of the leaf, and we do not want to strip it, as it
needs to be generated.
leaf foo {
type decimal64 {
fraction-digits 2;
}
default 1;
}
The leaf type's schema path will match the schema path of the leaf, and we DO want to strip it.