Search in sources :

Example 1 with ImmutableNormalizedMetadata

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;
    }
}
Also used : Builder(org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata.Builder)

Example 2 with ImmutableNormalizedMetadata

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);
    }
}
Also used : NormalizedNodeBuilder(org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder) Builder(org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata.Builder) ImmutableNormalizedMetadata(org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata)

Example 3 with ImmutableNormalizedMetadata

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;
        }
    }
}
Also used : Builder(org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata.Builder) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) ImmutableNormalizedMetadata(org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) ArrayDeque(java.util.ArrayDeque)

Aggregations

Builder (org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata.Builder)3 ImmutableNormalizedMetadata (org.opendaylight.yangtools.rfc7952.data.util.ImmutableNormalizedMetadata)2 ArrayDeque (java.util.ArrayDeque)1 RpcResultBuilder (org.opendaylight.yangtools.yang.common.RpcResultBuilder)1 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)1 NormalizedNodeBuilder (org.opendaylight.yangtools.yang.data.api.schema.builder.NormalizedNodeBuilder)1