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.Objects;
11 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
12 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
17 public class MustEffectiveStatementImpl extends
18 EffectiveStatementBase<RevisionAwareXPath, MustStatement> implements
21 private RevisionAwareXPath xPath;
22 private String description;
23 private String errorAppTag;
24 private String errorMessage;
25 private String reference;
27 public MustEffectiveStatementImpl(
28 StmtContext<RevisionAwareXPath, MustStatement, ?> ctx) {
33 xPath = ctx.getStatementArgument();
36 private void initFields() {
38 for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
40 if (effectiveStatement instanceof DescriptionEffectiveStatementImpl) {
41 description = ((DescriptionEffectiveStatementImpl) effectiveStatement).argument();
43 if (effectiveStatement instanceof ErrorAppTagEffectiveStatementImpl) {
44 errorAppTag = ((ErrorAppTagEffectiveStatementImpl) effectiveStatement).argument();
46 if (effectiveStatement instanceof ErrorMessageEffectiveStatementImpl) {
47 errorMessage = ((ErrorMessageEffectiveStatementImpl) effectiveStatement).argument();
49 if (effectiveStatement instanceof ReferenceEffectiveStatementImpl) {
50 reference = ((ReferenceEffectiveStatementImpl) effectiveStatement).argument();
56 public RevisionAwareXPath getXpath() {
61 public String getDescription() {
66 public String getErrorAppTag() {
71 public String getErrorMessage() {
76 public String getReference() {
81 public int hashCode() {
84 result = prime * result + Objects.hashCode(xPath);
85 result = prime * result + Objects.hashCode(description);
86 result = prime * result + Objects.hashCode(reference);
91 public boolean equals(final Object obj) {
98 if (getClass() != obj.getClass()) {
101 final MustEffectiveStatementImpl other = (MustEffectiveStatementImpl) obj;
103 if (other.xPath != null) {
106 } else if (!xPath.equals(other.xPath)) {
109 if (description == null) {
110 if (other.description != null) {
113 } else if (!description.equals(other.description)) {
116 if (reference == null) {
117 if (other.reference != null) {
120 } else if (!reference.equals(other.reference)) {
127 public String toString() {
128 return xPath.toString();