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=fcfbf112d695d5e67e595d67de73a51457070d43;hb=49a282bbe32153861accb2c90688a101de0571cc;hp=c5840cff986b359c5f4271a29c8a5fa6829e0eb6;hpb=9e5540fb30986583d69e51f9290dbb651338f4b0;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 c5840cff98..fcfbf112d6 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 @@ -75,12 +75,10 @@ public final class JSONCodecFactory { private final SchemaContext schemaContext; private final JSONCodec iidCodec; - private final JSONCodec idrefCodec; private JSONCodecFactory(final SchemaContext context) { this.schemaContext = Preconditions.checkNotNull(context); iidCodec = new JSONStringInstanceIdentifierCodec(context); - idrefCodec = new JSONStringIdentityrefCodec(context); } /** @@ -101,10 +99,15 @@ public final class JSONCodecFactory { return superType; } + @SuppressWarnings("unchecked") private JSONCodec createCodec(DataSchemaNode key, TypeDefinition type) { TypeDefinition baseType = resolveBaseTypeFrom(type); if (baseType instanceof LeafrefTypeDefinition) { return createReferencedTypeCodec(key, (LeafrefTypeDefinition) baseType); + } else if (baseType instanceof IdentityrefType) { + final JSONCodec jsonStringIdentityrefCodec = new JSONStringIdentityrefCodec(schemaContext, + key.getQName().getModule()); + return (JSONCodec) jsonStringIdentityrefCodec; } return createFromSimpleType(type); } @@ -114,7 +117,7 @@ public final class JSONCodecFactory { // FIXME: Verify if this does indeed support leafref of leafref TypeDefinition referencedType = SchemaContextUtil.getBaseTypeForLeafRef(type, getSchemaContext(), schema); - return createFromSimpleType(referencedType); + return createCodec(schema, referencedType); } @SuppressWarnings("unchecked") @@ -123,9 +126,6 @@ public final class JSONCodecFactory { if (baseType instanceof InstanceIdentifierType) { return (JSONCodec) iidCodec; } - if (baseType instanceof IdentityrefType) { - return (JSONCodec) idrefCodec; - } final TypeDefinitionAwareCodec codec = TypeDefinitionAwareCodec.from(type); if (codec == null) {