2 * Copyright (c) 2014 Cisco Systems, Inc. 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 com.google.common.base.Preconditions;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.util.AbstractModuleStringInstanceIdentifierCodec;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 final class JSONStringInstanceIdentifierCodec extends AbstractModuleStringInstanceIdentifierCodec implements JSONCodec<YangInstanceIdentifier> {
20 private final SchemaContext context;
22 JSONStringInstanceIdentifierCodec(final SchemaContext context) {
23 this.context = Preconditions.checkNotNull(context);
27 protected Module moduleForPrefix(final String prefix) {
28 return context.findModuleByName(prefix, null);
32 protected String prefixForNamespace(final URI namespace) {
33 final Module module = context.findModuleByNamespaceAndRevision(namespace, null);
34 return module == null ? null : module.getName();
38 public boolean needQuotes() {