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.DescriptionEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagEffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.MustEffectiveStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceEffectiveStatement;
20 import org.opendaylight.yangtools.yang.parser.rfc6020.util.DeclaredEffectiveStatementBase;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 public class MustEffectiveStatementImpl extends DeclaredEffectiveStatementBase<RevisionAwareXPath, MustStatement>
24 implements MustDefinition, MustEffectiveStatement {
26 private final RevisionAwareXPath xpath;
27 private final String description;
28 private final String errorAppTag;
29 private final String errorMessage;
30 private final String reference;
32 public MustEffectiveStatementImpl(final StmtContext<RevisionAwareXPath, MustStatement, ?> ctx) {
34 this.xpath = ctx.getStatementArgument();
36 DescriptionEffectiveStatement descriptionStmt = firstEffective(DescriptionEffectiveStatement.class);
37 this.description = descriptionStmt == null ? null : descriptionStmt.argument();
39 ErrorAppTagEffectiveStatement errorAppTagStmt = firstEffective(ErrorAppTagEffectiveStatement.class);
40 this.errorAppTag = errorAppTagStmt == null ? null : errorAppTagStmt.argument();
42 ErrorMessageEffectiveStatement errorMessageStmt = firstEffective(ErrorMessageEffectiveStatement.class);
43 this.errorMessage = errorMessageStmt == null ? null : errorMessageStmt.argument();
45 ReferenceEffectiveStatement referenceStmt = firstEffective(ReferenceEffectiveStatement.class);
46 this.reference = referenceStmt == null ? null : referenceStmt.argument();
50 public RevisionAwareXPath getXpath() {
55 public Optional<String> getDescription() {
56 return Optional.ofNullable(description);
60 public Optional<String> getErrorAppTag() {
61 return Optional.ofNullable(errorAppTag);
65 public Optional<String> getErrorMessage() {
66 return Optional.ofNullable(errorMessage);
70 public Optional<String> getReference() {
71 return Optional.ofNullable(reference);
75 public int hashCode() {
78 result = prime * result + Objects.hashCode(xpath);
79 result = prime * result + Objects.hashCode(description);
80 result = prime * result + Objects.hashCode(reference);
85 public boolean equals(final Object obj) {
92 if (getClass() != obj.getClass()) {
95 final MustEffectiveStatementImpl other = (MustEffectiveStatementImpl) obj;
96 if (!Objects.equals(xpath, other.xpath)) {
99 if (!Objects.equals(description, other.description)) {
102 if (!Objects.equals(reference, other.reference)) {
109 public String toString() {
110 return xpath.toString();