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.model.ri.stmt.DeclaredStatements;
17 import org.opendaylight.yangtools.yang.model.ri.stmt.EffectiveStatements;
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;
23 public final class DescriptionStatementSupport
24 extends AbstractStringStatementSupport<DescriptionStatement, DescriptionEffectiveStatement> {
25 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
26 YangStmtMapping.DESCRIPTION).build();
27 private static final DescriptionStatementSupport INSTANCE = new DescriptionStatementSupport();
29 private DescriptionStatementSupport() {
30 super(YangStmtMapping.DESCRIPTION, StatementPolicy.contextIndependent());
33 public static DescriptionStatementSupport getInstance() {
38 protected SubstatementValidator getSubstatementValidator() {
39 return SUBSTATEMENT_VALIDATOR;
43 protected DescriptionStatement createDeclared(final StmtContext<String, DescriptionStatement, ?> ctx,
44 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
45 return DeclaredStatements.createDescription(ctx.getRawArgument(), substatements);
49 protected DescriptionStatement createEmptyDeclared(final StmtContext<String, DescriptionStatement, ?> ctx) {
50 return DeclaredStatements.createDescription(ctx.getRawArgument());
54 protected DescriptionEffectiveStatement createEffective(final Current<String, DescriptionStatement> stmt,
55 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
56 return EffectiveStatements.createDescription(stmt.declared(), substatements);