Reformulate StatementContextFactory.createEffective()
[yangtools.git] / yang / rfc6643-parser-support / src / main / java / org / opendaylight / yangtools / rfc6643 / parser / DisplayHintStatementSupport.java
1 /*
2  * Copyright (c) 2016, 2020 PANTHEON.tech, 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.rfc6643.parser;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableList;
12 import org.opendaylight.yangtools.rfc6643.model.api.DisplayHintEffectiveStatement;
13 import org.opendaylight.yangtools.rfc6643.model.api.DisplayHintStatement;
14 import org.opendaylight.yangtools.rfc6643.model.api.IetfYangSmiv2ExtensionsMapping;
15 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
16 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
17 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
21
22 @Beta
23 public final class DisplayHintStatementSupport
24         extends BaseStringStatementSupport<DisplayHintStatement, DisplayHintEffectiveStatement> {
25     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
26             SubstatementValidator.builder(IetfYangSmiv2ExtensionsMapping.DISPLAY_HINT).build();
27     private static final DisplayHintStatementSupport INSTANCE = new DisplayHintStatementSupport();
28
29     private DisplayHintStatementSupport() {
30         super(IetfYangSmiv2ExtensionsMapping.DISPLAY_HINT);
31     }
32
33     public static DisplayHintStatementSupport getInstance() {
34         return INSTANCE;
35     }
36
37     @Override
38     protected SubstatementValidator getSubstatementValidator() {
39         return SUBSTATEMENT_VALIDATOR;
40     }
41
42     @Override
43     protected DisplayHintStatement createDeclared(final StmtContext<String, DisplayHintStatement, ?> ctx,
44             final ImmutableList<? extends DeclaredStatement<?>> substatements) {
45         return new DisplayHintStatementImpl(ctx.coerceRawStatementArgument(), substatements);
46     }
47
48     @Override
49     protected DisplayHintStatement createEmptyDeclared(final StmtContext<String, DisplayHintStatement, ?> ctx) {
50         return createDeclared(ctx, ImmutableList.of());
51     }
52
53     @Override
54     protected DisplayHintEffectiveStatement createEffective(final Current<String, DisplayHintStatement> stmt,
55             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
56         return new DisplayHintEffectiveStatementImpl(stmt, substatements);
57     }
58 }