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.DeclaredStatement;
17 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
22 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
25 public final class MaxAccessStatementSupport
26 extends AbstractStatementSupport<MaxAccess, MaxAccessStatement, MaxAccessEffectiveStatement> {
27 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
28 SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.MAX_ACCESS).build();
29 private static final MaxAccessStatementSupport INSTANCE = new MaxAccessStatementSupport();
31 private MaxAccessStatementSupport() {
32 super(IetfYangSmiv2ExtensionsMapping.MAX_ACCESS, StatementPolicy.contextIndependent());
35 public static MaxAccessStatementSupport getInstance() {
40 public MaxAccess parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
41 final MaxAccess val = MaxAccess.forStringLiteral(value);
43 throw new SourceException(ctx, "Invalid max-access value '%s'", value);
49 public String internArgument(final String rawArgument) {
50 final MaxAccess val = MaxAccess.forStringLiteral(rawArgument);
51 return val == null ? rawArgument : val.stringLiteral();
55 protected SubstatementValidator getSubstatementValidator() {
56 return SUBSTATEMENT_VALIDATOR;
60 protected MaxAccessStatement createDeclared(final StmtContext<MaxAccess, MaxAccessStatement, ?> ctx,
61 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
62 return new MaxAccessStatementImpl(ctx.getArgument(), substatements);
66 protected MaxAccessEffectiveStatement createEffective(final Current<MaxAccess, MaxAccessStatement> stmt,
67 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
68 return new MaxAccessEffectiveStatementImpl(stmt, substatements);