c0a0c0378d6a9960cb595ce889986525a2fa67f4
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / error_message / ErrorMessageStatementSupport.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.error_message;
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.ErrorMessageEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
16 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
19
20 public final class ErrorMessageStatementSupport
21         extends BaseStringStatementSupport<ErrorMessageStatement, ErrorMessageEffectiveStatement> {
22     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
23             SubstatementValidator.builder(YangStmtMapping.ERROR_MESSAGE).build();
24     private static final ErrorMessageStatementSupport INSTANCE = new ErrorMessageStatementSupport();
25
26     private ErrorMessageStatementSupport() {
27         super(YangStmtMapping.ERROR_MESSAGE);
28     }
29
30     public static ErrorMessageStatementSupport getInstance() {
31         return INSTANCE;
32     }
33
34     @Override
35     protected SubstatementValidator getSubstatementValidator() {
36         return SUBSTATEMENT_VALIDATOR;
37     }
38
39     @Override
40     protected ErrorMessageStatement createDeclared(final StmtContext<String, ErrorMessageStatement, ?> ctx,
41             final ImmutableList<? extends DeclaredStatement<?>> substatements) {
42         return new RegularErrorMessageStatement(ctx, substatements);
43     }
44
45     @Override
46     protected ErrorMessageStatement createEmptyDeclared(final StmtContext<String, ErrorMessageStatement, ?> ctx) {
47         return new EmptyErrorMessageStatement(ctx);
48     }
49
50     @Override
51     protected ErrorMessageEffectiveStatement createEffective(
52             final StmtContext<String, ErrorMessageStatement, ErrorMessageEffectiveStatement> ctx,
53             final ErrorMessageStatement declared,
54             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
55         return new RegularErrorMessageEffectiveStatement(declared, substatements);
56     }
57
58     @Override
59     protected ErrorMessageEffectiveStatement createEmptyEffective(
60             final StmtContext<String, ErrorMessageStatement, ErrorMessageEffectiveStatement> ctx,
61             final ErrorMessageStatement declared) {
62         return new EmptyErrorMessageEffectiveStatement(declared);
63     }
64 }