2 * Copyright (c) 2019 PANTHEON.tech 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.api.schema;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
14 import org.eclipse.jdt.annotation.NonNullByDefault;
15 import org.eclipse.jdt.annotation.Nullable;
18 * An entity able to resolve the SchemaContext for embedded mount points based on generic data provided by the current
19 * interpretation context.
23 public interface MountPointContextFactory {
25 * Top-level containers which hold YANG Library information, ordered by descending preference, with more modern
26 * and/or preferred entries first.
29 // Note: order this enum from most-preferred to least-preferred name
31 * Container in RFC8525 (NMDA) YANG Library.
33 RFC8525("yang-library"),
35 * Container in RFC7895 (pre-NMDA) YANG Library.
37 RFC7895("modules-state");
39 private final String localName;
41 ContainerName(final String localName) {
42 this.localName = requireNonNull(localName);
45 public String getLocalName() {
49 public static ContainerName ofLocalName(final String localName) {
50 final var ret = forLocalName(localName);
52 throw new IllegalArgumentException("Unrecognized container name '" + localName + "'");
57 public static @Nullable ContainerName forLocalName(final String localName) {
58 return switch (localName) {
59 case "yang-library" -> RFC8525;
60 case "modules-state" -> RFC7895;
67 * Create a mount point context based on available information. Implementations are expected to attempt to interpret
68 * provided data to their best of their ability.
70 * @param libraryContainers available YANG library containers in opaque format
71 * @param schemaMounts the content of 'schema-mounts' container, if available
72 * @return A {@link MountPointContext}
73 * @throws MountPointException if the schema cannot be assembled
75 MountPointContext createContext(Map<ContainerName, MountPointChild> libraryContainers,
76 @Nullable MountPointChild schemaMounts) throws MountPointException;