2 * Copyright (c) 2015 Cisco Systems, Inc. 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.parser.rfc7950.stmt.import_;
10 import com.google.common.base.MoreObjects;
11 import com.google.common.collect.ImmutableList;
12 import java.util.Optional;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.yangtools.concepts.SemVer;
15 import org.opendaylight.yangtools.yang.common.Revision;
16 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
17 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
20 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement.DefaultArgument.WithSubstatements;
21 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.DocumentedNodeMixin;
23 final class ImportEffectiveStatementImpl extends WithSubstatements<String, ImportStatement>
24 implements ImportEffectiveStatement, ModuleImport, DocumentedNodeMixin<String, ImportStatement> {
25 private final @Nullable Revision revision;
26 private final @Nullable SemVer semVer;
28 ImportEffectiveStatementImpl(final ImportStatement declared,
29 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
30 final @Nullable Revision revision, final @Nullable SemVer semVer) {
31 super(declared, substatements);
32 this.revision = revision;
37 public String getModuleName() {
42 public Optional<Revision> getRevision() {
43 return Optional.ofNullable(revision);
47 public Optional<SemVer> getSemanticVersion() {
48 return Optional.ofNullable(semVer);
52 public String getPrefix() {
53 return getDeclared().getPrefix().getValue();
57 public String toString() {
58 return MoreObjects.toStringHelper(this).omitNullValues()
59 .add("moduleName", getModuleName())
60 .add("revision", revision)
61 .add("version", semVer)
62 .add("prefix", getPrefix())
63 .add("description", getDescription().orElse(null))
64 .add("reference", getReference().orElse(null))