c7d7a65613d151e3ac126fc144e7b37183b96261
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / description / DescriptionStatementSupport.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.description;
9
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.EffectiveStatement;
13 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionEffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
15 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
18
19 public final class DescriptionStatementSupport
20         extends BaseStringStatementSupport<DescriptionStatement, DescriptionEffectiveStatement> {
21     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
22         YangStmtMapping.DESCRIPTION).build();
23     private static final DescriptionStatementSupport INSTANCE = new DescriptionStatementSupport();
24
25     private DescriptionStatementSupport() {
26         super(YangStmtMapping.DESCRIPTION);
27     }
28
29     public static DescriptionStatementSupport getInstance() {
30         return INSTANCE;
31     }
32
33     @Override
34     public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
35         return value;
36     }
37
38     @Override
39     public DescriptionStatement createDeclared(final StmtContext<String, DescriptionStatement, ?> ctx) {
40         return new DescriptionStatementImpl(ctx);
41     }
42
43     @Override
44     protected SubstatementValidator getSubstatementValidator() {
45         return SUBSTATEMENT_VALIDATOR;
46     }
47
48     @Override
49     protected DescriptionEffectiveStatement createEffective(
50             final StmtContext<String, DescriptionStatement, DescriptionEffectiveStatement> ctx,
51             final DescriptionStatement declared,
52             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
53         return new RegularDescriptionEffectiveStatement(declared, substatements);
54     }
55
56     @Override
57     protected DescriptionEffectiveStatement createEmptyEffective(
58             final StmtContext<String, DescriptionStatement, DescriptionEffectiveStatement> ctx,
59             final DescriptionStatement declared) {
60         return new EmptyDescriptionEffectiveStatement(declared);
61     }
62 }