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.description;
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.DescriptionEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
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 DescriptionStatementSupport
21 extends BaseStringStatementSupport<DescriptionStatement, DescriptionEffectiveStatement> {
22 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
23 YangStmtMapping.DESCRIPTION).build();
24 private static final DescriptionStatementSupport INSTANCE = new DescriptionStatementSupport();
26 private DescriptionStatementSupport() {
27 super(YangStmtMapping.DESCRIPTION);
30 public static DescriptionStatementSupport getInstance() {
35 protected SubstatementValidator getSubstatementValidator() {
36 return SUBSTATEMENT_VALIDATOR;
40 protected DescriptionStatement createDeclared(final StmtContext<String, DescriptionStatement, ?> ctx,
41 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
42 return new RegularDescriptionStatement(ctx.coerceRawStatementArgument(), substatements);
46 protected DescriptionStatement createEmptyDeclared(final StmtContext<String, DescriptionStatement, ?> ctx) {
47 return new EmptyDescriptionStatement(ctx.coerceRawStatementArgument());
51 protected DescriptionEffectiveStatement createEffective(
52 final StmtContext<String, DescriptionStatement, DescriptionEffectiveStatement> ctx,
53 final DescriptionStatement declared,
54 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
55 return new RegularDescriptionEffectiveStatement(declared, substatements);
59 protected DescriptionEffectiveStatement createEmptyEffective(
60 final StmtContext<String, DescriptionStatement, DescriptionEffectiveStatement> ctx,
61 final DescriptionStatement declared) {
62 return new EmptyDescriptionEffectiveStatement(declared);