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);
}
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);
}
}
}
Aggregations