2 * Copyright (c) 2017 Pantheon Technologies, 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.yang.parser.rfc7950.stmt.reference;
10 import com.google.common.collect.ImmutableList;
11 import java.util.Optional;
12 import org.opendaylight.yangtools.yang.common.QNameModule;
13 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
14 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
15 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
18 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
25 public final class ReferenceStatementSupport
26 extends BaseStringStatementSupport<ReferenceStatement, ReferenceEffectiveStatement> {
27 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
28 YangStmtMapping.REFERENCE)
30 private static final ReferenceStatementSupport INSTANCE = new ReferenceStatementSupport();
32 private ReferenceStatementSupport() {
33 super(YangStmtMapping.REFERENCE);
36 public static ReferenceStatementSupport getInstance() {
41 public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
46 public Optional<? extends Mutable<?, ?, ?>> copyAsChildOf(final Mutable<?, ?, ?> stmt,
47 final Mutable<?, ?, ?> parent, final CopyType type, final QNameModule targetModule) {
48 return StmtContextUtils.isChildOfGrouping(stmt) ? Optional.empty()
49 : super.copyAsChildOf(stmt, parent, type, targetModule);
53 protected SubstatementValidator getSubstatementValidator() {
54 return SUBSTATEMENT_VALIDATOR;
58 protected ReferenceStatement createDeclared(final StmtContext<String, ReferenceStatement, ?> ctx,
59 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
60 return new RegularReferenceStatement(ctx, substatements);
64 protected ReferenceStatement createEmptyDeclared(final StmtContext<String, ReferenceStatement, ?> ctx) {
65 return new EmptyReferenceStatement(ctx);
69 protected ReferenceEffectiveStatement createEffective(
70 final StmtContext<String, ReferenceStatement, ReferenceEffectiveStatement> ctx,
71 final ReferenceStatement declared,
72 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
73 return new RegularReferenceEffectiveStatement(declared, substatements);
77 protected ReferenceEffectiveStatement createEmptyEffective(
78 final StmtContext<String, ReferenceStatement, ReferenceEffectiveStatement> ctx,
79 final ReferenceStatement declared) {
80 return new EmptyReferenceEffectiveStatement(declared);