Update yang-parser-api
[yangtools.git] / yang / rfc6643-parser-support / src / main / java / org / opendaylight / yangtools / rfc6643 / parser / ImpliedStatementSupport.java
1 /*
2  * Copyright (c) 2016, 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.rfc6643.parser;
9
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.ImpliedEffectiveStatement;
14 import org.opendaylight.yangtools.rfc6643.model.api.ImpliedStatement;
15 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
16 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
17 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStringStatementSupport;
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
23 @Beta
24 public final class ImpliedStatementSupport
25         extends AbstractStringStatementSupport<ImpliedStatement, ImpliedEffectiveStatement> {
26     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
27             SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.IMPLIED).build();
28
29     public ImpliedStatementSupport(final YangParserConfiguration config) {
30         super(IetfYangSmiv2ExtensionsMapping.IMPLIED, StatementPolicy.contextIndependent(), config);
31     }
32
33     @Override
34     protected SubstatementValidator getSubstatementValidator() {
35         return SUBSTATEMENT_VALIDATOR;
36     }
37
38     @Override
39     protected ImpliedStatement createDeclared(final StmtContext<String, ImpliedStatement, ?> ctx,
40             final ImmutableList<? extends DeclaredStatement<?>> substatements) {
41         return new ImpliedStatementImpl(ctx.getRawArgument(), substatements);
42     }
43
44     @Override
45     protected ImpliedEffectiveStatement createEffective(final Current<String, ImpliedStatement> stmt,
46             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
47         return new ImpliedEffectiveStatementImpl(stmt, substatements);
48     }
49 }