Search in sources :

Example 1 with ContainerName

use of org.opendaylight.yangtools.rfc8528.data.api.YangLibraryConstants.ContainerName in project yangtools by opendaylight.

the class AbstractDynamicMountPointContextFactory method createContext.

@Override
public final MountPointContext createContext(final Map<ContainerName, MountPointChild> libraryContainers, final MountPointChild schemaMounts) throws YangParserException {
    for (Entry<ContainerName, MountPointChild> entry : libraryContainers.entrySet()) {
        // Context for the specific code word
        final Optional<EffectiveModelContext> optLibContext = findSchemaForLibrary(entry.getKey());
        if (optLibContext.isEmpty()) {
            LOG.debug("YANG Library context for mount point {} container {} not found", getIdentifier(), entry.getKey());
            continue;
        }
        final NormalizedNode libData;
        try {
            libData = entry.getValue().normalizeTo(optLibContext.get());
        } catch (IOException e) {
            throw new YangParserException("Failed to interpret yang-library data", e);
        }
        if (!(libData instanceof ContainerNode)) {
            throw new YangParserException("Invalid yang-library non-container " + libData);
        }
        final EffectiveModelContext schemaContext = bindLibrary(entry.getKey(), (ContainerNode) libData);
        if (schemaMounts == null) {
            return new EmptyMountPointContext(schemaContext);
        }
        final NormalizedNode mountData;
        try {
            mountData = schemaMounts.normalizeTo(schemaContext);
        } catch (IOException e) {
            throw new YangParserException("Failed to interpret schema-mount data", e);
        }
        if (!(mountData instanceof ContainerNode)) {
            throw new YangParserException("Invalid schema-mount non-container " + mountData);
        }
        return createMountPointContext(schemaContext, (ContainerNode) mountData);
    }
    throw new YangParserException("Failed to interpret " + libraryContainers);
}
Also used : ContainerName(org.opendaylight.yangtools.rfc8528.data.api.YangLibraryConstants.ContainerName) MountPointChild(org.opendaylight.yangtools.rfc8528.data.api.MountPointChild) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) IOException(java.io.IOException) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) YangParserException(org.opendaylight.yangtools.yang.parser.api.YangParserException) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)

Example 2 with ContainerName

use of org.opendaylight.yangtools.rfc8528.data.api.YangLibraryConstants.ContainerName in project yangtools by opendaylight.

the class MountPointData method setContainer.

public void setContainer(@NonNull final ContainerName containerName, @NonNull final MountPointChild data) {
    final MountPointChild prev = yangLib.putIfAbsent(containerName, requireNonNull(data));
    checkState(prev == null, "Attempted to duplicate container %s data %s with %s", containerName, prev, data);
    addChild(data);
}
Also used : MountPointChild(org.opendaylight.yangtools.rfc8528.data.api.MountPointChild)

Aggregations

MountPointChild (org.opendaylight.yangtools.rfc8528.data.api.MountPointChild)2 IOException (java.io.IOException)1 ContainerName (org.opendaylight.yangtools.rfc8528.data.api.YangLibraryConstants.ContainerName)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)1 EffectiveModelContext (org.opendaylight.yangtools.yang.model.api.EffectiveModelContext)1 YangParserException (org.opendaylight.yangtools.yang.parser.api.YangParserException)1