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.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 DescriptionStatementSupport
22 extends BaseStringStatementSupport<DescriptionStatement, DescriptionEffectiveStatement> {
23 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
24 YangStmtMapping.DESCRIPTION).build();
25 private static final DescriptionStatementSupport INSTANCE = new DescriptionStatementSupport();
27 private DescriptionStatementSupport() {
28 super(YangStmtMapping.DESCRIPTION, CopyPolicy.CONTEXT_INDEPENDENT);
31 public static DescriptionStatementSupport getInstance() {
36 protected SubstatementValidator getSubstatementValidator() {
37 return SUBSTATEMENT_VALIDATOR;
41 protected DescriptionStatement createDeclared(final StmtContext<String, DescriptionStatement, ?> ctx,
42 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
43 return new RegularDescriptionStatement(ctx.getRawArgument(), substatements);
47 protected DescriptionStatement createEmptyDeclared(final StmtContext<String, DescriptionStatement, ?> ctx) {
48 return new EmptyDescriptionStatement(ctx.getRawArgument());
52 protected DescriptionEffectiveStatement createEffective(final Current<String, DescriptionStatement> stmt,
53 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
54 return substatements.isEmpty() ? new EmptyDescriptionEffectiveStatement(stmt.declared())
55 : new RegularDescriptionEffectiveStatement(stmt.declared(), substatements);