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.stmt.rfc6020.effective;
10 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
12 import java.util.Date;
13 import java.util.Objects;
14 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
15 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 public class ImportEffectiveStatementImpl extends EffectiveStatementBase<String, ImportStatement> implements
22 private String moduleName;
23 private Date revision;
24 private String prefix;
26 public ImportEffectiveStatementImpl(StmtContext<String, ImportStatement, ?> ctx) {
29 moduleName = ctx.getStatementArgument();
30 revision = SimpleDateFormatUtil.DEFAULT_DATE_IMP;
32 for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
33 if (effectiveStatement instanceof RevisionDateEffectiveStatementImpl) {
34 revision = ((RevisionDateEffectiveStatementImpl) effectiveStatement).argument();
36 if (effectiveStatement instanceof PrefixEffectiveStatementImpl) {
37 prefix = ((PrefixEffectiveStatementImpl) effectiveStatement).argument();
43 public String getModuleName() {
48 public Date getRevision() {
53 public String getPrefix() {
58 public int hashCode() {
61 result = prime * result + Objects.hashCode(moduleName);
62 result = prime * result + Objects.hashCode(revision);
63 result = prime * result + Objects.hashCode(prefix);
68 public boolean equals(Object obj) {
75 if (getClass() != obj.getClass()) {
78 ImportEffectiveStatementImpl other = (ImportEffectiveStatementImpl) obj;
79 if (getModuleName() == null) {
80 if (other.getModuleName() != null) {
83 } else if (!getModuleName().equals(other.getModuleName())) {
86 if (getRevision() == null) {
87 if (other.getRevision() != null) {
90 } else if (!getRevision().equals(other.getRevision())) {
93 if (getPrefix() == null) {
94 if (other.getPrefix() != null) {
97 } else if (!getPrefix().equals(other.getPrefix())) {
104 public String toString() {
105 return ImportEffectiveStatementImpl.class.getSimpleName() + "[moduleName=" + moduleName + ", revision="
106 + revision + ", prefix=" + prefix + "]";