2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.data.codec.gson;
10 import static com.google.common.base.Preconditions.checkArgument;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.common.QNameModule;
14 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
16 final class RFC7951JSONInstanceIdentifierCodec extends JSONInstanceIdentifierCodec {
17 RFC7951JSONInstanceIdentifierCodec(final EffectiveModelContext context, final JSONCodecFactory jsonCodecFactory) {
18 super(context, jsonCodecFactory);
22 protected StringBuilder appendQName(final StringBuilder sb, final QName qname, final QNameModule lastModule) {
23 if (qname.getModule().equals(lastModule)) {
24 return sb.append(qname.getLocalName());
27 return super.appendQName(sb, qname, lastModule);
31 protected QName createQName(final QNameModule lastModule, final String localName) {
32 checkArgument(lastModule != null, "Unprefixed leading name %s", localName);
33 return QName.create(lastModule, localName);