aea5d7ee6619fe0a505c1ed9352428be42ee05c5
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / SemanticVersionStatementImpl.java
1 /*
2  * Copyright (c) 2016 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 com.google.common.annotations.Beta;
11 import org.opendaylight.yangtools.concepts.SemVer;
12 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
13 import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionNamespace;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.SemanticVersionEffectiveStatementImpl;
19
20 @Beta
21 public final class SemanticVersionStatementImpl extends AbstractDeclaredStatement<SemVer> implements
22         UnknownStatement<SemVer> {
23
24     SemanticVersionStatementImpl(
25             StmtContext<SemVer, UnknownStatement<SemVer>, ?> context) {
26         super(context);
27     }
28
29     public static class SemanticVersionSupport
30             extends
31             AbstractStatementSupport<SemVer, UnknownStatement<SemVer>, EffectiveStatement<SemVer, UnknownStatement<SemVer>>> {
32
33         public SemanticVersionSupport() {
34             super(SupportedExtensionsMapping.SEMANTIC_VERSION);
35         }
36
37         @Override
38         public SemVer parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
39             return SemVer.valueOf(value) ;
40         }
41
42         @Override
43         public void onLinkageDeclared(StmtContext.Mutable<SemVer,UnknownStatement<SemVer>,EffectiveStatement<SemVer,UnknownStatement<SemVer>>> stmt) {
44             stmt.addToNs(SemanticVersionNamespace.class, stmt.getParentContext(), stmt.getStatementArgument());
45         }
46
47         @Override
48         public UnknownStatement<SemVer> createDeclared(
49                 StmtContext<SemVer, UnknownStatement<SemVer>, ?> ctx) {
50             return new SemanticVersionStatementImpl(ctx);
51         }
52
53         @Override
54         public EffectiveStatement<SemVer, UnknownStatement<SemVer>> createEffective(
55                 final StmtContext<SemVer, UnknownStatement<SemVer>, EffectiveStatement<SemVer, UnknownStatement<SemVer>>> ctx) {
56             return new SemanticVersionEffectiveStatementImpl(ctx);
57         }
58     }
59
60     @Override
61     public SemVer getArgument() {
62         return argument();
63     }
64 }