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.EffectiveStmtCtx.Current;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
21 public final class ReferenceStatementSupport
22 extends BaseStringStatementSupport<ReferenceStatement, ReferenceEffectiveStatement> {
23 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
24 YangStmtMapping.REFERENCE)
26 private static final ReferenceStatementSupport INSTANCE = new ReferenceStatementSupport();
28 private ReferenceStatementSupport() {
29 super(YangStmtMapping.REFERENCE);
32 public static ReferenceStatementSupport getInstance() {
37 protected SubstatementValidator getSubstatementValidator() {
38 return SUBSTATEMENT_VALIDATOR;
42 protected ReferenceStatement createDeclared(final StmtContext<String, ReferenceStatement, ?> ctx,
43 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
44 return new RegularReferenceStatement(ctx.coerceRawStatementArgument(), substatements);
48 protected ReferenceStatement createEmptyDeclared(final StmtContext<String, ReferenceStatement, ?> ctx) {
49 return new EmptyReferenceStatement(ctx.coerceRawStatementArgument());
53 protected ReferenceEffectiveStatement createEffective(final Current<String, ReferenceStatement> stmt,
54 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
55 return substatements.isEmpty() ? new EmptyReferenceEffectiveStatement(stmt.declared())
56 : new RegularReferenceEffectiveStatement(stmt.declared(), substatements);