2 * Copyright (c) 2020 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.ir;
10 import static com.google.common.base.Preconditions.checkArgument;
11 import static java.util.Objects.requireNonNull;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.yangtools.yang.ir.IRKeyword.Unqualified;
16 import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
17 import org.opendaylight.yangtools.yang.model.api.source.YangSourceRepresentation;
19 public final class YangIRSchemaSource implements YangSourceRepresentation {
20 private final @NonNull SourceIdentifier sourceId;
21 private final @NonNull IRStatement rootStatement;
22 private final @Nullable String symbolicName;
24 public YangIRSchemaSource(final @NonNull SourceIdentifier sourceId, final @NonNull IRStatement rootStatement,
25 final @Nullable String symbolicName) {
26 this.sourceId = requireNonNull(sourceId);
27 this.rootStatement = requireNonNull(rootStatement);
28 this.symbolicName = symbolicName;
30 final IRKeyword rootKeyword = rootStatement.keyword();
31 checkArgument(rootKeyword instanceof Unqualified, "Root statement has invalid keyword %s", rootKeyword);
32 final String rootName = rootKeyword.identifier();
38 throw new IllegalArgumentException("Invalid root statement keyword " + rootName);
41 checkArgument(rootStatement.argument() != null, "Root statement does not have an argument");
45 public SourceIdentifier sourceId() {
50 public String symbolicName() {
55 public Class<YangIRSchemaSource> getType() {
56 return YangIRSchemaSource.class;
60 * Return the root statement of this source.
62 * @return Root statement.
64 public @NonNull IRStatement getRootStatement() {