2 * Copyright (c) 2013 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.stmt.rfc6020.effective;
10 import com.google.common.base.Preconditions;
11 import java.util.Date;
12 import java.util.Objects;
13 import org.opendaylight.yangtools.concepts.SemVer;
14 import org.opendaylight.yangtools.yang.model.api.Module;
15 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
17 final class ModuleImportImpl implements ModuleImport {
18 private final String moduleName;
19 private final Date revision;
20 private final SemVer semVer;
21 private final String prefix;
23 public ModuleImportImpl(final String moduleName, final Date revision, final String prefix) {
24 this(moduleName, revision, prefix, Module.DEFAULT_SEMANTIC_VERSION);
27 public ModuleImportImpl(final String moduleName, final Date revision, final String prefix, final SemVer semVer) {
28 this.moduleName = Preconditions.checkNotNull(moduleName, "Module name must not be null.");
29 this.revision = revision;
30 this.prefix = Preconditions.checkNotNull(prefix, "Import prefix must not be null.");
31 this.semVer = Preconditions.checkNotNull(semVer, "Semantic version of module must not be null.");
35 public String getModuleName() {
40 public Date getRevision() {
45 public SemVer getSemanticVersion() {
50 public String getPrefix() {
55 public int hashCode() {
58 result = prime * result + Objects.hashCode(moduleName);
59 result = prime * result + Objects.hashCode(revision);
60 result = prime * result + Objects.hashCode(prefix);
61 result = prime * result + Objects.hashCode(semVer);
66 public boolean equals(final Object obj) {
73 if (getClass() != obj.getClass()) {
76 ModuleImport other = (ModuleImport) obj;
77 if (!Objects.equals(getModuleName(), other.getModuleName())) {
80 if (!Objects.equals(getRevision(), other.getRevision())) {
83 if (!Objects.equals(getPrefix(), other.getPrefix())) {
86 if (!Objects.equals(getSemanticVersion(), other.getSemanticVersion())) {
93 public String toString() {
94 return "ModuleImport[moduleName=" + moduleName + ", revision=" + revision + ", prefix=" + prefix + "]";