[YANGTOOLS-14] Built-in type should return null for getBaseType() Created: 12/Sep/13  Updated: 10/Apr/22  Resolved: 17/Sep/13

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Christopher Hartley Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Windows
Platform: PC


External issue ID: 70

 Description   

When calling getBaseType() on a built in type, it should return null.
Currently it seems to be returning itself.

This would allow code like that below to work.

public static TypeDefinition getRootType(final TypeDefinition typeDef) {
assert typeDef != null;

TypeDefinition t = typeDef;

while (t.getBaseType() != null)

{ t = t.getBaseType(); }
return t;
}

currently I need to do :

public static TypeDefinition getRootType(final TypeDefinition typeDef) {
assert typeDef != null;

TypeDefinition t = typeDef;

while ((t.getBaseType() != null) && (!t.getQName().getLocalName().equals(t.getBaseType().getQName().getLocalName()))) { t = t.getBaseType(); }

return t;
}



 Comments   
Comment by Christopher Hartley [ 12/Sep/13 ]

The javadocs should be updated too. Something like :

If this is a derived type, then it returns the type that it is derived from.
If this is a built in type, then it returns null.

Comment by Martin Vitez [ 17/Sep/13 ]

Fixed in version 0.5.8-SNAPSHOT.

Generated at Wed Feb 07 20:52:01 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.