+ /**
+ * Create an immutable list node.
+ *
+ * @param name QName which will be used as node identifier
+ * @return An unkeyed list node
+ */
+ public static @NonNull UnkeyedListNode listNode(final QName name) {
+ return ImmutableUnkeyedListNodeBuilder.create().withNodeIdentifier(NodeIdentifier.create(name)).build();
+ }
+
+ /**
+ * Convert YangInstanceIdentifier into a normalized node structure.
+ *
+ * @param ctx schema context to used during serialization
+ * @param id instance identifier to convert to node structure starting from root
+ * @return serialized normalized node for provided instance Id
+ */
+ public static @NonNull NormalizedNode<?, ?> fromInstanceId(final SchemaContext ctx,
+ final YangInstanceIdentifier id) {
+ return fromInstanceId(ctx, id, Optional.empty(), Optional.empty());
+ }
+
+ /**
+ * Convert YangInstanceIdentifier into a normalized node structure.
+ *
+ * @param ctx schema context to used during serialization
+ * @param id instance identifier to convert to node structure starting from root
+ * @param deepestElement pre-built deepest child that will be inserted at the last path argument of provided
+ * instance identifier
+ * @return serialized normalized node for provided instance Id with overridden last child.
+ */
+ public static @NonNull NormalizedNode<?, ?> fromInstanceId(final SchemaContext ctx, final YangInstanceIdentifier id,
+ final NormalizedNode<?, ?> deepestElement) {
+ return fromInstanceId(ctx, id, Optional.of(deepestElement), Optional.empty());
+ }
+
+ /**
+ * Convert YangInstanceIdentifier into a normalized node structure.
+ *
+ * @param ctx schema context to used during serialization
+ * @param id instance identifier to convert to node structure starting from root
+ * @param deepestElement pre-built deepest child that will be inserted at the last path argument of provided
+ * instance identifier
+ * @param operation modify operation attribute to be added to the deepest child. QName is the operation attribute
+ * key and ModifyAction is the value.
+ * @return serialized normalized node for provided instance Id with (optionally) overridden last child
+ * and (optionally) marked with specific operation attribute.
+ */
+ public static @NonNull NormalizedNode<?, ?> fromInstanceId(final SchemaContext ctx, final YangInstanceIdentifier id,
+ final Optional<NormalizedNode<?, ?>> deepestElement, final Optional<Entry<QName, ModifyAction>> operation) {
+ final PathArgument topLevelElement;
+ final InstanceIdToNodes<?> instanceIdToNodes;
+ final Iterator<PathArgument> it = id.getPathArguments().iterator();
+ if (it.hasNext()) {
+ topLevelElement = it.next();
+ final DataSchemaNode dataChildByName = ctx.getDataChildByName(topLevelElement.getNodeType());
+ checkNotNull(dataChildByName,
+ "Cannot find %s node in schema context. Instance identifier has to start from root", topLevelElement);
+ instanceIdToNodes = InstanceIdToNodes.fromSchemaAndQNameChecked(ctx, topLevelElement.getNodeType());
+ } else {
+ topLevelElement = SCHEMACONTEXT_NAME;
+ instanceIdToNodes = InstanceIdToNodes.fromDataSchemaNode(ctx);
+ }
+
+ return instanceIdToNodes.create(topLevelElement, it, deepestElement, operation);