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;
10 import javax.annotation.Nonnull;
11 import javax.annotation.Nullable;
12 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
13 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
20 import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
24 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.MustEffectiveStatementImpl;
26 public class MustStatementImpl extends AbstractDeclaredStatement<RevisionAwareXPath> implements MustStatement {
27 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
29 .addOptional(YangStmtMapping.DESCRIPTION)
30 .addOptional(YangStmtMapping.ERROR_APP_TAG)
31 .addOptional(YangStmtMapping.ERROR_MESSAGE)
32 .addOptional(YangStmtMapping.REFERENCE)
35 protected MustStatementImpl(final StmtContext<RevisionAwareXPath, MustStatement, ?> context) {
39 public static class Definition extends
40 AbstractStatementSupport<RevisionAwareXPath, MustStatement, EffectiveStatement<RevisionAwareXPath, MustStatement>> {
43 super(YangStmtMapping.MUST);
47 public RevisionAwareXPath parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
48 return Utils.parseXPath(ctx, value);
52 public MustStatement createDeclared(final StmtContext<RevisionAwareXPath, MustStatement, ?> ctx) {
53 return new MustStatementImpl(ctx);
57 public EffectiveStatement<RevisionAwareXPath, MustStatement> createEffective(
58 final StmtContext<RevisionAwareXPath, MustStatement, EffectiveStatement<RevisionAwareXPath, MustStatement>> ctx) {
59 return new MustEffectiveStatementImpl(ctx);
63 protected SubstatementValidator getSubstatementValidator() {
64 return SUBSTATEMENT_VALIDATOR;
70 public RevisionAwareXPath getCondition() {
76 public ErrorAppTagStatement getErrorAppTagStatement() {
77 return firstDeclared(ErrorAppTagStatement.class);
82 public ErrorMessageStatement getErrorMessageStatement() {
83 return firstDeclared(ErrorMessageStatement.class);
88 public DescriptionStatement getDescription() {
89 return firstDeclared(DescriptionStatement.class);
94 public ReferenceStatement getReference() {
95 return firstDeclared(ReferenceStatement.class);