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.StmtContext;
17 public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, ImportStatement> implements
20 private final String moduleName;
21 private final Date revision;
22 private final String prefix;
24 public ImportEffectiveStatementImpl(final StmtContext<String, ImportStatement, ?> ctx) {
27 moduleName = ctx.getStatementArgument();
29 RevisionDateEffectiveStatementImpl revisionDateStmt = firstEffective(RevisionDateEffectiveStatementImpl.class);
30 this.revision = (revisionDateStmt == null) ? SimpleDateFormatUtil.DEFAULT_DATE_IMP : revisionDateStmt.argument();
32 PrefixEffectiveStatementImpl prefixStmt = firstEffective(PrefixEffectiveStatementImpl.class);
33 if (prefixStmt != null ) {
34 this.prefix = prefixStmt.argument();
36 throw new IllegalStateException("Prefix is mandatory substatement of import statement");
41 public String getModuleName() {
46 public Date getRevision() {
51 public String getPrefix() {
56 public int hashCode() {
59 result = prime * result + Objects.hashCode(moduleName);
60 result = prime * result + Objects.hashCode(revision);
61 result = prime * result + Objects.hashCode(prefix);
66 public boolean equals(final Object obj) {
73 if (getClass() != obj.getClass()) {
76 ImportEffectiveStatementImpl other = (ImportEffectiveStatementImpl) obj;
77 if (!Objects.equals(getModuleName(), other.getModuleName())) {
80 if (!Objects.equals(getRevision(), other.getRevision())) {
83 if (!Objects.equals(getPrefix(), other.getPrefix())) {
90 public String toString() {
91 return ImportEffectiveStatementImpl.class.getSimpleName() + "[moduleName=" + moduleName + ", revision="
92 + revision + ", prefix=" + prefix + "]";