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.MustStatement;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
17 public class MustEffectiveStatementImpl extends DeclaredEffectiveStatementBase<RevisionAwareXPath, MustStatement>
18 implements MustDefinition {
20 private final RevisionAwareXPath xpath;
21 private final String description;
22 private final String errorAppTag;
23 private final String errorMessage;
24 private final String reference;
26 public MustEffectiveStatementImpl(final StmtContext<RevisionAwareXPath, MustStatement, ?> ctx) {
28 this.xpath = ctx.getStatementArgument();
30 DescriptionEffectiveStatementImpl descriptionStmt = firstEffective(DescriptionEffectiveStatementImpl.class);
31 this.description = descriptionStmt == null ? null : descriptionStmt.argument();
33 ErrorAppTagEffectiveStatementImpl errorAppTagStmt = firstEffective(ErrorAppTagEffectiveStatementImpl.class);
34 this.errorAppTag = errorAppTagStmt == null ? null : errorAppTagStmt.argument();
36 ErrorMessageEffectiveStatementImpl errorMessageStmt = firstEffective(ErrorMessageEffectiveStatementImpl.class);
37 this.errorMessage = errorMessageStmt == null ? null : errorMessageStmt.argument();
39 ReferenceEffectiveStatementImpl referenceStmt = firstEffective(ReferenceEffectiveStatementImpl.class);
40 this.reference = referenceStmt == null ? null : referenceStmt.argument();
44 public RevisionAwareXPath getXpath() {
49 public Optional<String> getDescription() {
50 return Optional.ofNullable(description);
54 public Optional<String> getErrorAppTag() {
55 return Optional.ofNullable(errorAppTag);
59 public Optional<String> getErrorMessage() {
60 return Optional.ofNullable(errorMessage);
64 public Optional<String> getReference() {
65 return Optional.ofNullable(reference);
69 public int hashCode() {
72 result = prime * result + Objects.hashCode(xpath);
73 result = prime * result + Objects.hashCode(description);
74 result = prime * result + Objects.hashCode(reference);
79 public boolean equals(final Object obj) {
86 if (getClass() != obj.getClass()) {
89 final MustEffectiveStatementImpl other = (MustEffectiveStatementImpl) obj;
90 if (!Objects.equals(xpath, other.xpath)) {
93 if (!Objects.equals(description, other.description)) {
96 if (!Objects.equals(reference, other.reference)) {
103 public String toString() {
104 return xpath.toString();