2 * Copyright (c) 2024 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.spi.source;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableSet;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.yangtools.yang.common.Revision;
16 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
17 import org.opendaylight.yangtools.yang.common.YangVersion;
18 import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
21 * Linkage information about a particular {@link SourceRepresentation}. It has two specializations
23 * <li>{@link ModuleSourceInfo} pertaining to {@link SourceRepresentation} which have {@code module} as its root
25 * <li>{@link SubmoduleSourceInfo} pertaining to {@link SourceRepresentation} which have {@code submodule} as its root
30 * This interface captures the basic metadata needed for interpretation and linkage of the source, as represented by the
31 * following ABNF constructs placed at the start of a YANG file:
33 * <li>{@code module-header-stmts} or {@code submodule-header-stmts}</li>
34 * <li>{@code linkage-stmts}</li>
35 * <li>{@code revision-stmts}<li>
39 public sealed interface SourceInfo permits ModuleSourceInfo, SubmoduleSourceInfo {
40 record Import(Unqualified name, String prefix, @Nullable Revision revision) {
43 requireNonNull(prefix);
47 record Include(Unqualified name, @Nullable Revision revision) {
54 * The name of this source, as expressed by the argument of {@code module} or {@code submodule} statement.
56 * @return name of this source.
61 * {@link YangVersion} of the source. If no {@code yang-version} is present, this method will return
62 * {@link YangVersion#VERSION_1}.
64 * @return {@link YangVersion} of the source
66 YangVersion yangVersion();
68 ImmutableSet<Revision> revisions();
70 ImmutableSet<Import> imports();
72 ImmutableSet<Include> includes();