BUG-4638: fix UnionTypeCodec 41/30041/8
authorRobert Varga <robert.varga@pantheon.sk>
Sat, 21 Nov 2015 17:59:03 +0000 (18:59 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 30 Nov 2015 16:13:16 +0000 (16:13 +0000)
The codec should be checking for UnionTypeDefinition, not UnionType.

Change-Id: I6a4ca9070c068451d16008c6b258d212319d363e
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/impl/UnionTypeCodec.java

index 00702f07296d5e92d886d9020a746f9d67e3bd3a..cc063580c1f8d5598213b2b656d0da229ecbf1b3 100644 (file)
@@ -18,7 +18,6 @@ import org.opendaylight.yangtools.concepts.Codec;
 import org.opendaylight.yangtools.yang.binding.BindingMapping;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.yangtools.yang.model.util.UnionType;
 
 final class UnionTypeCodec extends ReflectionBasedCodec {
 
@@ -53,9 +52,9 @@ final class UnionTypeCodec extends ReflectionBasedCodec {
     }
 
     private static Codec<Object, Object> getCodecForType(final Class<?> valueType, final TypeDefinition<?> subtype) {
-        if (subtype.getBaseType() instanceof UnionType) {
+        if (subtype.getBaseType() instanceof UnionTypeDefinition) {
             try {
-                return UnionTypeCodec.loader(valueType, (UnionType) subtype.getBaseType()).call();
+                return UnionTypeCodec.loader(valueType, (UnionTypeDefinition) subtype.getBaseType()).call();
             } catch (final Exception e) {
                 throw new IllegalStateException("Could not construct Union Type Codec");
             }