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 org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
12 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
16 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
20 public final class ReferenceStatementSupport
21 extends BaseStringStatementSupport<ReferenceStatement, ReferenceEffectiveStatement> {
22 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
23 YangStmtMapping.REFERENCE)
25 private static final ReferenceStatementSupport INSTANCE = new ReferenceStatementSupport();
27 private ReferenceStatementSupport() {
28 super(YangStmtMapping.REFERENCE);
31 public static ReferenceStatementSupport getInstance() {
36 protected SubstatementValidator getSubstatementValidator() {
37 return SUBSTATEMENT_VALIDATOR;
41 protected ReferenceStatement createDeclared(final StmtContext<String, ReferenceStatement, ?> ctx,
42 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
43 return new RegularReferenceStatement(ctx.coerceRawStatementArgument(), substatements);
47 protected ReferenceStatement createEmptyDeclared(final StmtContext<String, ReferenceStatement, ?> ctx) {
48 return new EmptyReferenceStatement(ctx.coerceRawStatementArgument());
52 protected ReferenceEffectiveStatement createEffective(
53 final StmtContext<String, ReferenceStatement, ReferenceEffectiveStatement> ctx,
54 final ReferenceStatement declared,
55 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
56 return new RegularReferenceEffectiveStatement(declared, substatements);
60 protected ReferenceEffectiveStatement createEmptyEffective(
61 final StmtContext<String, ReferenceStatement, ReferenceEffectiveStatement> ctx,
62 final ReferenceStatement declared) {
63 return new EmptyReferenceEffectiveStatement(declared);