X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-data-codec-gson%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fcodec%2Fgson%2FJSONCodecFactory.java;h=1d6ffc827724a1670da028bdc5a34cc9810ccc43;hb=e704e6a6d1cc4db7ac1e1f53b54ec3bf51aaecc3;hp=9df9b347dc16c59a19931c650814420d59a8c221;hpb=12b8e81a0f434cc7eef885dec2954e0e6ecc04ff;p=yangtools.git diff --git a/yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONCodecFactory.java b/yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONCodecFactory.java index 9df9b347dc..1d6ffc8277 100644 --- a/yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONCodecFactory.java +++ b/yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONCodecFactory.java @@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.data.codec.gson; import com.google.common.annotations.Beta; import com.google.common.base.Preconditions; +import com.google.common.base.Verify; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -80,7 +81,7 @@ public final class JSONCodecFactory { private JSONCodecFactory(final SchemaContext context) { this.schemaContext = Preconditions.checkNotNull(context); - iidCodec = new JSONStringInstanceIdentifierCodec(context); + iidCodec = new JSONStringInstanceIdentifierCodec(context, this); } /** @@ -111,6 +112,7 @@ public final class JSONCodecFactory { // FIXME: Verify if this does indeed support leafref of leafref final TypeDefinition referencedType = SchemaContextUtil.getBaseTypeForLeafRef(type, getSchemaContext(), schema); + Verify.verifyNotNull(referencedType, "Unable to find base type for leafref node '%s'.", schema.getPath()); return createCodec(schema, referencedType); } @@ -120,7 +122,7 @@ public final class JSONCodecFactory { return (JSONCodec) iidCodec; } if (type instanceof EmptyTypeDefinition) { - return (JSONCodec) JSONEmptyCodec.INSTANCE; + return JSONEmptyCodec.INSTANCE; } final TypeDefinitionAwareCodec codec = TypeDefinitionAwareCodec.from(type);