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 java.util.Date;
11 import java.util.Objects;
12 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
13 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18 public class ImportEffectiveStatementImpl extends EffectiveStatementBase<String, ImportStatement> implements
21 private final String moduleName;
22 private Date revision;
23 private String prefix;
25 public ImportEffectiveStatementImpl(final StmtContext<String, ImportStatement, ?> ctx) {
28 moduleName = ctx.getStatementArgument();
29 revision = SimpleDateFormatUtil.DEFAULT_DATE_IMP;
31 for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
32 if (effectiveStatement instanceof RevisionDateEffectiveStatementImpl) {
33 revision = ((RevisionDateEffectiveStatementImpl) effectiveStatement).argument();
35 if (effectiveStatement instanceof PrefixEffectiveStatementImpl) {
36 prefix = ((PrefixEffectiveStatementImpl) effectiveStatement).argument();
42 public String getModuleName() {
47 public Date getRevision() {
52 public String getPrefix() {
57 public int hashCode() {
60 result = prime * result + Objects.hashCode(moduleName);
61 result = prime * result + Objects.hashCode(revision);
62 result = prime * result + Objects.hashCode(prefix);
67 public boolean equals(final Object obj) {
74 if (getClass() != obj.getClass()) {
77 ImportEffectiveStatementImpl other = (ImportEffectiveStatementImpl) obj;
78 if (!Objects.equals(getModuleName(), other.getModuleName())) {
81 if (!Objects.equals(getRevision(), other.getRevision())) {
84 if (!Objects.equals(getPrefix(), other.getPrefix())) {
91 public String toString() {
92 return ImportEffectiveStatementImpl.class.getSimpleName() + "[moduleName=" + moduleName + ", revision="
93 + revision + ", prefix=" + prefix + "]";