2fd845bf93b261d5f9c42db33948228883fe5c0d
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / presence / PresenceStatementSupport.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.presence;
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.PresenceEffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
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 PresenceStatementSupport
20         extends BaseStringStatementSupport<PresenceStatement, PresenceEffectiveStatement> {
21     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
22             SubstatementValidator.builder(YangStmtMapping.PRESENCE).build();
23     private static final PresenceStatementSupport INSTANCE = new PresenceStatementSupport();
24
25     private PresenceStatementSupport() {
26         super(YangStmtMapping.PRESENCE);
27     }
28
29     public static PresenceStatementSupport 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 PresenceStatement createDeclared(final StmtContext<String, PresenceStatement, ?> ctx) {
40         return new PresenceStatementImpl(ctx);
41     }
42
43     @Override
44     protected SubstatementValidator getSubstatementValidator() {
45         return SUBSTATEMENT_VALIDATOR;
46     }
47
48     @Override
49     protected PresenceEffectiveStatement createEffective(
50             final StmtContext<String, PresenceStatement, PresenceEffectiveStatement> ctx,
51             final PresenceStatement declared,
52             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
53         return new RegularPresenceEffectiveStatement(declared, substatements);
54     }
55
56     @Override
57     protected PresenceEffectiveStatement createEmptyEffective(
58             final StmtContext<String, PresenceStatement, PresenceEffectiveStatement> ctx,
59             final PresenceStatement declared) {
60         return new EmptyPresenceEffectiveStatement(declared);
61     }
62 }