2 * Copyright (c) 2016 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.restconf.server.spi;
10 import static java.util.Objects.requireNonNull;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.restconf.server.api.DatabindContext;
14 import org.opendaylight.yangtools.yang.common.QNameModule;
15 import org.opendaylight.yangtools.yang.common.XMLNamespace;
16 import org.opendaylight.yangtools.yang.data.util.AbstractStringInstanceIdentifierCodec;
17 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
18 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.util.LeafrefResolver;
22 final class ApiPathInstanceIdentifierCodec extends AbstractStringInstanceIdentifierCodec {
23 private final @NonNull DatabindContext databind;
25 ApiPathInstanceIdentifierCodec(final DatabindContext databind) {
26 this.databind = requireNonNull(databind);
30 protected DataSchemaContextTree getDataContextTree() {
31 return databind.schemaTree();
35 protected QNameModule moduleForPrefix(final String prefix) {
36 return databind.modelContext().findModuleStatements(prefix).stream().findFirst()
37 .map(ModuleEffectiveStatement::localQNameModule)
42 protected String prefixForNamespace(final XMLNamespace namespace) {
43 return databind.modelContext().findModuleStatements(namespace).stream().findFirst()
44 .map(module -> module.argument().getLocalName())
49 protected Object deserializeKeyValue(final DataSchemaNode schemaNode, final LeafrefResolver resolver,
51 throw new UnsupportedOperationException("FIXME: implement this method");