Search in sources :

Example 1 with StreamWriterMountPointExtension

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

the class MountPointNormalizedNodeWriter method forwardingFor.

@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE", justification = "SpotBugs does not grok checkArgument()")
@NonNull
public static MountPointNormalizedNodeWriter forwardingFor(final NormalizedNodeStreamWriter writer) {
    final StreamWriterMountPointExtension mountWriter = writer.getExtensions().getInstance(StreamWriterMountPointExtension.class);
    checkArgument(mountWriter != null, "Writer %s does not support mount points", writer);
    return new Forwarding(writer, mountWriter);
}
Also used : StreamWriterMountPointExtension(org.opendaylight.yangtools.rfc8528.data.api.StreamWriterMountPointExtension) Objects.requireNonNull(java.util.Objects.requireNonNull) NonNull(org.eclipse.jdt.annotation.NonNull) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 2 with StreamWriterMountPointExtension

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

the class MountPointData method write.

void write(@NonNull final NormalizedNodeStreamWriter writer) throws IOException {
    final StreamWriterMountPointExtension mountWriter = writer.getExtensions().getInstance(StreamWriterMountPointExtension.class);
    if (mountWriter == null) {
        LOG.debug("Writer {} does not support mount points, ignoring data in {}", writer, getIdentifier());
        return;
    }
    final MountPointContext mountCtx;
    try {
        mountCtx = contextFactory.createContext(yangLib, schemaMounts);
    } catch (YangParserException e) {
        throw new IOException("Failed to resolve mount point " + getIdentifier(), e);
    }
    try (NormalizedNodeStreamWriter nestedWriter = mountWriter.startMountPoint(getIdentifier(), mountCtx)) {
        for (MountPointChild child : children) {
            child.writeTo(nestedWriter, mountCtx);
        }
    }
}
Also used : NormalizedNodeStreamWriter(org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter) MountPointChild(org.opendaylight.yangtools.rfc8528.data.api.MountPointChild) IOException(java.io.IOException) StreamWriterMountPointExtension(org.opendaylight.yangtools.rfc8528.data.api.StreamWriterMountPointExtension) MountPointContext(org.opendaylight.yangtools.rfc8528.data.api.MountPointContext) YangParserException(org.opendaylight.yangtools.yang.parser.api.YangParserException)

Aggregations

StreamWriterMountPointExtension (org.opendaylight.yangtools.rfc8528.data.api.StreamWriterMountPointExtension)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 IOException (java.io.IOException)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 MountPointChild (org.opendaylight.yangtools.rfc8528.data.api.MountPointChild)1 MountPointContext (org.opendaylight.yangtools.rfc8528.data.api.MountPointContext)1 NormalizedNodeStreamWriter (org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter)1 YangParserException (org.opendaylight.yangtools.yang.parser.api.YangParserException)1