Move KeyEffectiveStatement implementations
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / meta / PrefixStatementSupport.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.meta;
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.DeclaredStatement;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
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;
22
23 public final class PrefixStatementSupport
24         extends AbstractStringStatementSupport<PrefixStatement, PrefixEffectiveStatement> {
25     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
26             SubstatementValidator.builder(YangStmtMapping.PREFIX).build();
27     private static final PrefixStatementSupport INSTANCE = new PrefixStatementSupport();
28
29     private PrefixStatementSupport() {
30         super(YangStmtMapping.PREFIX, StatementPolicy.reject());
31     }
32
33     public static PrefixStatementSupport getInstance() {
34         return INSTANCE;
35     }
36
37     @Override
38     protected SubstatementValidator getSubstatementValidator() {
39         return SUBSTATEMENT_VALIDATOR;
40     }
41
42     @Override
43     protected PrefixStatement createDeclared(final StmtContext<String, PrefixStatement, ?> ctx,
44             final ImmutableList<? extends DeclaredStatement<?>> substatements) {
45         return DeclaredStatements.createPrefix(ctx.getRawArgument(), substatements);
46     }
47
48     @Override
49     protected PrefixEffectiveStatement createEffective(final Current<String, PrefixStatement> stmt,
50             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
51         return EffectiveStatements.createPrefix(stmt.declared(), substatements);
52     }
53 }