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.Objects;
13 import java.util.Optional;
14 import org.eclipse.jdt.annotation.Nullable;
15 import org.opendaylight.yangtools.concepts.SemVer;
16 import org.opendaylight.yangtools.yang.common.Revision;
17 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
18 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
21 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredEffectiveStatement.DefaultArgument.WithSubstatements;
22 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.DocumentedNodeMixin;
24 final class ImportEffectiveStatementImpl extends WithSubstatements<String, ImportStatement>
25 implements ImportEffectiveStatement, ModuleImport, DocumentedNodeMixin<String, ImportStatement> {
26 private final @Nullable Revision revision;
27 private final @Nullable SemVer semVer;
29 ImportEffectiveStatementImpl(final ImportStatement declared,
30 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
31 final @Nullable Revision revision, final @Nullable SemVer semVer) {
32 super(declared, substatements);
33 this.revision = revision;
38 public String getModuleName() {
43 public Optional<Revision> getRevision() {
44 return Optional.ofNullable(revision);
48 public Optional<SemVer> getSemanticVersion() {
49 return Optional.ofNullable(semVer);
53 public String getPrefix() {
54 return getDeclared().getPrefix().getValue();
58 public int hashCode() {
59 return Objects.hash(getModuleName(), revision, getPrefix(), semVer, getDescription().orElse(null),
60 getReference().orElse(null));
64 public boolean equals(final Object obj) {
71 if (getClass() != obj.getClass()) {
74 final ImportEffectiveStatementImpl other = (ImportEffectiveStatementImpl) obj;
75 return Objects.equals(getModuleName(), other.getModuleName()) && Objects.equals(revision, other.revision)
76 && Objects.equals(semVer, other.semVer) && Objects.equals(getPrefix(), other.getPrefix())
77 && Objects.equals(getDescription(), other.getDescription())
78 && Objects.equals(getReference(), other.getReference());
82 public String toString() {
83 return MoreObjects.toStringHelper(this).omitNullValues()
84 .add("moduleName", getModuleName())
85 .add("revision", revision)
86 .add("version", semVer)
87 .add("prefix", getPrefix())
88 .add("description", getDescription().orElse(null))
89 .add("reference", getReference().orElse(null))