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.stmt.ImportStatement;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.MissingSubstatementException;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18 public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, ImportStatement> implements
21 private final String moduleName;
22 private final Date revision;
23 private final String prefix;
25 public ImportEffectiveStatementImpl(final StmtContext<String, ImportStatement, ?> ctx) {
28 moduleName = ctx.getStatementArgument();
30 RevisionDateEffectiveStatementImpl revisionDateStmt = firstEffective(RevisionDateEffectiveStatementImpl.class);
31 this.revision = (revisionDateStmt == null) ? SimpleDateFormatUtil.DEFAULT_DATE_IMP : revisionDateStmt.argument();
33 PrefixEffectiveStatementImpl prefixStmt = firstEffective(PrefixEffectiveStatementImpl.class);
34 if (prefixStmt != null) {
35 this.prefix = prefixStmt.argument();
37 throw new MissingSubstatementException("Prefix is mandatory substatement of import statement",
38 ctx.getStatementSourceReference());
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(final Object obj) {
75 if (getClass() != obj.getClass()) {
78 ImportEffectiveStatementImpl other = (ImportEffectiveStatementImpl) obj;
79 if (!Objects.equals(getModuleName(), other.getModuleName())) {
82 if (!Objects.equals(getRevision(), other.getRevision())) {
85 if (!Objects.equals(getPrefix(), other.getPrefix())) {
92 public String toString() {
93 return ImportEffectiveStatementImpl.class.getSimpleName() + "[moduleName=" + moduleName + ", revision="
94 + revision + ", prefix=" + prefix + "]";