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 java.util.Optional;
12 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
13 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
14 import org.opendaylight.yangtools.yang.model.api.stmt.MustEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18 public class MustEffectiveStatementImpl extends DeclaredEffectiveStatementBase<RevisionAwareXPath, MustStatement>
19 implements MustDefinition, MustEffectiveStatement {
21 private final RevisionAwareXPath xpath;
22 private final String description;
23 private final String errorAppTag;
24 private final String errorMessage;
25 private final String reference;
27 public MustEffectiveStatementImpl(final StmtContext<RevisionAwareXPath, MustStatement, ?> ctx) {
29 this.xpath = ctx.getStatementArgument();
31 DescriptionEffectiveStatementImpl descriptionStmt = firstEffective(DescriptionEffectiveStatementImpl.class);
32 this.description = descriptionStmt == null ? null : descriptionStmt.argument();
34 ErrorAppTagEffectiveStatementImpl errorAppTagStmt = firstEffective(ErrorAppTagEffectiveStatementImpl.class);
35 this.errorAppTag = errorAppTagStmt == null ? null : errorAppTagStmt.argument();
37 ErrorMessageEffectiveStatementImpl errorMessageStmt = firstEffective(ErrorMessageEffectiveStatementImpl.class);
38 this.errorMessage = errorMessageStmt == null ? null : errorMessageStmt.argument();
40 ReferenceEffectiveStatementImpl referenceStmt = firstEffective(ReferenceEffectiveStatementImpl.class);
41 this.reference = referenceStmt == null ? null : referenceStmt.argument();
45 public RevisionAwareXPath getXpath() {
50 public Optional<String> getDescription() {
51 return Optional.ofNullable(description);
55 public Optional<String> getErrorAppTag() {
56 return Optional.ofNullable(errorAppTag);
60 public Optional<String> getErrorMessage() {
61 return Optional.ofNullable(errorMessage);
65 public Optional<String> getReference() {
66 return Optional.ofNullable(reference);
70 public int hashCode() {
73 result = prime * result + Objects.hashCode(xpath);
74 result = prime * result + Objects.hashCode(description);
75 result = prime * result + Objects.hashCode(reference);
80 public boolean equals(final Object obj) {
87 if (getClass() != obj.getClass()) {
90 final MustEffectiveStatementImpl other = (MustEffectiveStatementImpl) obj;
91 if (!Objects.equals(xpath, other.xpath)) {
94 if (!Objects.equals(description, other.description)) {
97 if (!Objects.equals(reference, other.reference)) {
104 public String toString() {
105 return xpath.toString();