From a0140cbc277edd4ca10d9c7e862af5ea2901e3cd Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 17 Nov 2015 17:31:34 +0100 Subject: [PATCH] Do not rely on ExtendedType when looking for the base type A base type can be recognized as having its base type null, use that indicator instead of specific implementation class. Also change the implementation to use a simple loop instead of recursion. Change-Id: Iff3e78c618bcbb7a33ae7335ea3bafe7cdf203a6 Signed-off-by: Robert Varga --- .../sal/binding/yang/types/TypeProviderImpl.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java index 3aedd9d2f0..85ea46b1f1 100644 --- a/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java +++ b/binding/mdsal-binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java @@ -426,7 +426,7 @@ public final class TypeProviderImpl implements TypeProvider { /** * Gets base type definition for extendTypeDef. The method is - * recursivelly called until non ExtendedType type is found. + * recursively called until non ExtendedType type is found. * * @param extendTypeDef * type definition for which is the base type definition sought @@ -434,17 +434,15 @@ public final class TypeProviderImpl implements TypeProvider { * @throws IllegalArgumentException * if extendTypeDef equal null */ - private TypeDefinition baseTypeDefForExtendedType(final TypeDefinition extendTypeDef) { + private static TypeDefinition baseTypeDefForExtendedType(final TypeDefinition extendTypeDef) { Preconditions.checkArgument(extendTypeDef != null, "Type Definition reference cannot be NULL!"); - final TypeDefinition baseTypeDef = extendTypeDef.getBaseType(); - if (baseTypeDef == null) { - return extendTypeDef; - } else if (baseTypeDef instanceof ExtendedType) { - return baseTypeDefForExtendedType(baseTypeDef); - } else { - return baseTypeDef; + + TypeDefinition ret = extendTypeDef; + while (ret.getBaseType() != null) { + ret = ret.getBaseType(); } + return ret; } /** -- 2.36.6