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%2FJSONStringIdentityrefCodec.java;h=032553193bcb40d318750b0e203a240cbd5af6bf;hb=c24d6e2f39acbb11e22b5676bb7481ed52bec461;hp=7b00dc5dd2c132c3987cfd833d7a1bf0240c6213;hpb=a8b36814f85ef7a6d52ed57990142741324d6cc7;p=yangtools.git diff --git a/yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONStringIdentityrefCodec.java b/yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONStringIdentityrefCodec.java index 7b00dc5dd2..032553193b 100644 --- a/yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONStringIdentityrefCodec.java +++ b/yang/yang-data-codec-gson/src/main/java/org/opendaylight/yangtools/yang/data/codec/gson/JSONStringIdentityrefCodec.java @@ -7,28 +7,22 @@ */ package org.opendaylight.yangtools.yang.data.codec.gson; -import com.google.common.base.Preconditions; import com.google.gson.stream.JsonWriter; import java.io.IOException; -import java.net.URI; - +import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.QNameModule; -import org.opendaylight.yangtools.yang.data.util.AbstractModuleStringIdentityrefCodec; +import org.opendaylight.yangtools.yang.data.util.ModuleStringIdentityrefCodec; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -final class JSONStringIdentityrefCodec extends AbstractModuleStringIdentityrefCodec implements JSONCodec { - private final SchemaContext context; - private final QNameModule parentModuleQname; - +final class JSONStringIdentityrefCodec extends ModuleStringIdentityrefCodec implements JSONCodec { JSONStringIdentityrefCodec(final SchemaContext context, final QNameModule parentModule) { - this.context = Preconditions.checkNotNull(context); - this.parentModuleQname = Preconditions.checkNotNull(parentModule); + super(context, parentModule); } @Override - protected Module moduleForPrefix(final String prefix) { + protected Module moduleForPrefix(@Nonnull final String prefix) { if (prefix.isEmpty()) { return context.findModuleByNamespaceAndRevision(parentModuleQname.getNamespace(), parentModuleQname.getRevision()); @@ -37,17 +31,6 @@ final class JSONStringIdentityrefCodec extends AbstractModuleStringIdentityrefCo } } - @Override - protected String prefixForNamespace(final URI namespace) { - final Module module = context.findModuleByNamespaceAndRevision(namespace, null); - return module == null ? null : module.getName(); - } - - @Override - public boolean needQuotes() { - return true; - } - /** * Serialize QName with specified JsonWriter. *