use of org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata in project yangtools by opendaylight.
the class ImmutableNormalizedMetadataStreamWriter method exit.
public void exit() {
checkNotDone();
final ImmutableNormalizedMetadata metadata = builders.pop().build();
final Builder parent = builders.peek();
if (parent != null) {
if (!metadata.getAnnotations().isEmpty()) {
parent.withChild(metadata);
}
} else {
result = metadata;
}
}
use of org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata in project yangtools by opendaylight.
the class ImmutableMetadataNormalizedNodeStreamWriter method endNode.
@Override
public final void endNode() {
super.endNode();
final ImmutableNormalizedMetadata metadata = builders.pop().build();
final Builder current = builders.peek();
if (current != null) {
if (!metadata.getAnnotations().isEmpty() || !metadata.getChildren().isEmpty()) {
current.withChild(metadata);
}
} else {
// All done
result.setResult(metadata);
}
}
use of org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata in project netconf by opendaylight.
the class NetconfMessageTransformUtil method leafMetadata.
private static NormalizedMetadata leafMetadata(final YangInstanceIdentifier path, final ModifyAction oper) {
final List<PathArgument> args = path.getPathArguments();
final Deque<Builder> builders = new ArrayDeque<>(args.size());
// Step one: open builders
for (PathArgument arg : args) {
builders.push(ImmutableNormalizedMetadata.builder().withIdentifier(arg));
}
// Step two: set the top builder's metadata
builders.peek().withAnnotation(NETCONF_OPERATION_QNAME_LEGACY, oper.toString().toLowerCase(Locale.US));
// Step three: build the tree
while (true) {
final ImmutableNormalizedMetadata currentMeta = builders.pop().build();
final Builder parent = builders.peek();
if (parent != null) {
parent.withChild(currentMeta);
} else {
return currentMeta;
}
}
}
Aggregations