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.model.ri.stmt.impl.eff;
10 import com.google.common.collect.ImmutableList;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNull;
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.model.repo.api.SemVerSourceIdentifier;
21 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
22 import org.opendaylight.yangtools.yang.model.spi.meta.AbstractDeclaredEffectiveStatement.DefaultArgument.WithSubstatements;
23 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.DocumentedNodeMixin;
25 public final class ImportEffectiveStatementImpl extends WithSubstatements<String, ImportStatement>
26 implements ImportEffectiveStatement, ModuleImport, DocumentedNodeMixin<String, ImportStatement> {
27 private final @Nullable Revision revision;
28 private final @Nullable SemVer semVer;
30 public ImportEffectiveStatementImpl(final ImportStatement declared,
31 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
32 final @NonNull SourceIdentifier importedSource) {
33 super(declared, substatements);
34 revision = importedSource.getRevision().orElse(null);
35 semVer = importedSource instanceof SemVerSourceIdentifier
36 ? ((SemVerSourceIdentifier) importedSource).getSemanticVersion().orElse(null)
41 public Optional<Revision> getRevision() {
42 return Optional.ofNullable(revision);
46 public Optional<SemVer> getSemanticVersion() {
47 return Optional.ofNullable(semVer);
51 public String getPrefix() {
52 return getDeclared().getPrefix().argument();
56 public ImportEffectiveStatement asEffectiveStatement() {