2 * Copyright (c) 2016, 2020 PANTHEON.tech, s.r.o. 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.rfc6643.parser;
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableList;
12 import org.opendaylight.yangtools.rfc6643.model.api.IetfYangSmiv2ExtensionsMapping;
13 import org.opendaylight.yangtools.rfc6643.model.api.MaxAccess;
14 import org.opendaylight.yangtools.rfc6643.model.api.MaxAccessEffectiveStatement;
15 import org.opendaylight.yangtools.rfc6643.model.api.MaxAccessStatement;
16 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
17 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
18 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
19 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
24 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
27 public final class MaxAccessStatementSupport
28 extends AbstractStatementSupport<MaxAccess, MaxAccessStatement, MaxAccessEffectiveStatement> {
29 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
30 SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.MAX_ACCESS).build();
32 public MaxAccessStatementSupport(final YangParserConfiguration config) {
33 super(IetfYangSmiv2ExtensionsMapping.MAX_ACCESS, StatementPolicy.contextIndependent(), config);
37 public MaxAccess parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
38 final MaxAccess val = MaxAccess.forStringLiteral(value);
40 throw new SourceException(ctx, "Invalid max-access value '%s'", value);
46 public String internArgument(final String rawArgument) {
47 final MaxAccess val = MaxAccess.forStringLiteral(rawArgument);
48 return val == null ? rawArgument : val.stringLiteral();
52 protected SubstatementValidator getSubstatementValidator() {
53 return SUBSTATEMENT_VALIDATOR;
57 protected MaxAccessStatement createDeclared(final StmtContext<MaxAccess, MaxAccessStatement, ?> ctx,
58 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
59 return new MaxAccessStatementImpl(ctx.getArgument(), substatements);
63 protected MaxAccessStatement attachDeclarationReference(final MaxAccessStatement stmt,
64 final DeclarationReference reference) {
65 return new RefMaxAccessStatement(stmt, reference);
69 protected MaxAccessEffectiveStatement createEffective(final Current<MaxAccess, MaxAccessStatement> stmt,
70 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
71 return new MaxAccessEffectiveStatementImpl(stmt, substatements);