376511663e411b8a66114dacc1bae68661ba191f
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / ModuleImportImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.model.util;
9
10 import java.util.Date;
11 import java.util.Objects;
12 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
13
14 public final class ModuleImportImpl implements ModuleImport {
15     private final String moduleName;
16     private final Date revision;
17     private final String prefix;
18
19     public ModuleImportImpl(final String moduleName, final Date revision, final String prefix) {
20         this.moduleName = moduleName;
21         this.revision = revision;
22         this.prefix = prefix;
23     }
24
25     @Override
26     public String getModuleName() {
27         return moduleName;
28     }
29
30     @Override
31     public Date getRevision() {
32         return revision;
33     }
34
35     @Override
36     public String getPrefix() {
37         return prefix;
38     }
39
40     @Override
41     public int hashCode() {
42         final int prime = 31;
43         int result = 1;
44         result = prime * result + Objects.hashCode(moduleName);
45         result = prime * result + Objects.hashCode(revision);
46         result = prime * result + Objects.hashCode(prefix);
47         return result;
48     }
49
50     @Override
51     public boolean equals(final Object obj) {
52         if (this == obj) {
53             return true;
54         }
55         if (obj == null) {
56             return false;
57         }
58         if (getClass() != obj.getClass()) {
59             return false;
60         }
61         ModuleImport other = (ModuleImport) obj;
62         if (!Objects.equals(getModuleName(), other.getModuleName())) {
63             return false;
64         }
65         if (!Objects.equals(getRevision(), other.getRevision())) {
66             return false;
67         }
68         if (!Objects.equals(getPrefix(), other.getPrefix())) {
69             return false;
70         }
71         return true;
72     }
73
74     @Override
75     public String toString() {
76         return "ModuleImport[moduleName=" + moduleName + ", revision=" + revision + ", prefix=" + prefix + "]";
77     }
78
79 }
80