Reduce use of yang.model.api
[yangtools.git] / codec / yang-data-codec-xml / src / main / java / org / opendaylight / yangtools / yang / data / codec / xml / InstanceIdentifierSerializer.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.data.codec.xml;
9
10 import java.util.List;
11 import java.util.Map.Entry;
12 import javax.xml.namespace.NamespaceContext;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.yangtools.yang.common.QNameModule;
15 import org.opendaylight.yangtools.yang.common.XMLNamespace;
16 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
17 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
18 import org.opendaylight.yangtools.yang.model.util.LeafrefResolver;
19
20 final class InstanceIdentifierSerializer extends AbstractInstanceIdentifierCodec {
21     private final NamespacePrefixes prefixes;
22
23     InstanceIdentifierSerializer(final DataSchemaContextTree dataContextTree,  final NamespaceContext nsContext,
24             final @Nullable PreferredPrefixes pref) {
25         super(dataContextTree);
26         prefixes = new NamespacePrefixes(nsContext, pref);
27     }
28
29     List<Entry<XMLNamespace, String>> emittedPrefixes() {
30         return prefixes.emittedPrefixes();
31     }
32
33     @Override
34     protected QNameModule moduleForPrefix(final String prefix) {
35         // This is deserialize() path, we do not support that in this class
36         throw new UnsupportedOperationException("Not implemented");
37     }
38
39     @Override
40     protected String prefixForNamespace(final XMLNamespace namespace) {
41         return prefixes.encodePrefix(namespace);
42     }
43
44     @Override
45     protected Object deserializeKeyValue(final DataSchemaNode schemaNode, final LeafrefResolver resolver,
46             final String value) {
47         // This is deserialize() path, we do not support that in this class
48         throw new UnsupportedOperationException("Not implemented");
49     }
50 }