Add DataSchemaContextNode/SchemaInferenceStack integration
[yangtools.git] / data / yang-data-util / src / main / java / org / opendaylight / yangtools / yang / data / util / AbstractListLikeContextNode.java
1 /*
2  * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.data.util;
9
10 import org.opendaylight.yangtools.yang.common.QName;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
12 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
13 import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
14
15 /**
16  * An {@link AbstractMixinContextNode} which corresponding to a {@code list} or {@code leaf-list} node. NormalizedNode
17  * representation of these nodes is similar to JSON encoding and therefore we have two {@link DataSchemaContextNode}
18  * levels backed by a single {@link DataSchemaNode}.
19  */
20 abstract class AbstractListLikeContextNode<T extends PathArgument> extends AbstractMixinContextNode<T> {
21     AbstractListLikeContextNode(final T identifier, final DataSchemaNode schema) {
22         super(identifier, schema);
23     }
24
25     @Override
26     protected final DataSchemaContextNode<?> enterChild(final QName child, final SchemaInferenceStack stack) {
27         // Stack is already pointing to the corresponding statement, now we are just working with the child
28         return getChild(child);
29     }
30
31     @Override
32     protected final DataSchemaContextNode<?> enterChild(final PathArgument child, final SchemaInferenceStack stack) {
33         return getChild(child);
34     }
35 }