8f4842f0e60330085e25f20fb5d5f767bd696176
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / ModelDefinedStatementSupport.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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.stmt.rfc6020;
9
10 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
11 import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
12 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
13 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
14 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
15
16 /**
17  * StatementSupport for statements defined via YANG extensions. This is implemented by piggy-backing
18  * to a {@link UnknownStatementImpl.Definition}.
19  *
20  * @author Robert Varga
21  */
22 public final class ModelDefinedStatementSupport extends AbstractStatementSupport<String,
23         UnknownStatement<String>, EffectiveStatement<String, UnknownStatement<String>>> {
24     private final UnknownStatementImpl.Definition definition;
25
26     ModelDefinedStatementSupport(final ModelDefinedStatementDefinition publicDefinition) {
27         super(publicDefinition);
28         this.definition = new UnknownStatementImpl.Definition(publicDefinition);
29     }
30
31     @Override
32     public UnknownStatement<String> createDeclared(final StmtContext<String, UnknownStatement<String>, ?> ctx) {
33         return definition.createDeclared(ctx);
34     }
35
36     @Override
37     public EffectiveStatement<String, UnknownStatement<String>> createEffective(
38             final StmtContext<String, UnknownStatement<String>, EffectiveStatement<String, UnknownStatement<String>>> ctx) {
39         return definition.createEffective(ctx);
40     }
41
42     @Override
43     public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) throws SourceException {
44         return definition.parseArgumentValue(ctx, value);
45     }
46 }