2 * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.model.api;
10 import com.google.common.collect.ImmutableList;
11 import java.util.List;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
14 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
17 * An {@link EffectiveStatementInference} consisting purely of steps along the {@code schema tree} axis, so that it
18 * represents a {@code schema tree node} based on resolution of {@code absolute-schema-nodeid} as specified by
19 * <a href="https://tools.ietf.org/html/rfc7950#section-6.5">RFC7950 section 6.5</a>.
21 public interface SchemaTreeInference extends EffectiveStatementInference {
26 * The statement path is always composed on {@link SchemaTreeEffectiveStatement}s and contains at least one element.
27 * The path is ordered from conceptual YANG root, i.e. the first element corresponds to the first element in
28 * {@link SchemaNodeIdentifier.Absolute#firstNodeIdentifier()}.
31 List<@NonNull SchemaTreeEffectiveStatement<?>> statementPath();
34 * Return the {@link SchemaNodeIdentifier.Absolute} which resulted in this inference.
37 * Default implementation interprets {@link #statementPath()}'s arguments as the ordered source of
38 * {@link SchemaNodeIdentifier.Absolute} steps.
40 * @return An absolute SchemaNodeIdentifier
42 default SchemaNodeIdentifier.Absolute toSchemaNodeIdentifier() {
43 return SchemaNodeIdentifier.Absolute.of(statementPath().stream()
44 .map(SchemaTreeEffectiveStatement::argument)
45 .collect(ImmutableList.toImmutableList()));