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.rfc7950.stmt.must;
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.rfc7950.stmt.DeclaredEffectiveStatementBase;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 final 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 MustEffectiveStatementImpl(final StmtContext<RevisionAwareXPath, MustStatement, ?> ctx) {
34 xpath = ctx.getStatementArgument();
35 description = findFirstEffectiveSubstatementArgument(DescriptionEffectiveStatement.class).orElse(null);
36 errorAppTag = findFirstEffectiveSubstatementArgument(ErrorAppTagEffectiveStatement.class).orElse(null);
37 errorMessage = findFirstEffectiveSubstatementArgument(ErrorMessageEffectiveStatement.class).orElse(null);
38 reference = findFirstEffectiveSubstatementArgument(ReferenceEffectiveStatement.class).orElse(null);
42 public RevisionAwareXPath getXpath() {
47 public Optional<String> getDescription() {
48 return Optional.ofNullable(description);
52 public Optional<String> getErrorAppTag() {
53 return Optional.ofNullable(errorAppTag);
57 public Optional<String> getErrorMessage() {
58 return Optional.ofNullable(errorMessage);
62 public Optional<String> getReference() {
63 return Optional.ofNullable(reference);
67 public int hashCode() {
70 result = prime * result + Objects.hashCode(xpath);
71 result = prime * result + Objects.hashCode(description);
72 result = prime * result + Objects.hashCode(reference);
77 public boolean equals(final Object obj) {
84 if (getClass() != obj.getClass()) {
87 final MustEffectiveStatementImpl other = (MustEffectiveStatementImpl) obj;
88 if (!Objects.equals(xpath, other.xpath)) {
91 if (!Objects.equals(description, other.description)) {
94 if (!Objects.equals(reference, other.reference)) {
101 public String toString() {
102 return xpath.toString();