2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
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.SubstatementValidator;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionNamespace;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
20 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.SemanticVersionEffectiveStatementImpl;
24 public final class SemanticVersionStatementImpl extends AbstractDeclaredStatement<SemVer> implements
25 UnknownStatement<SemVer> {
26 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
27 SupportedExtensionsMapping.SEMANTIC_VERSION).build();
29 SemanticVersionStatementImpl(
30 final StmtContext<SemVer, UnknownStatement<SemVer>, ?> context) {
34 public static class SemanticVersionSupport
36 AbstractStatementSupport<SemVer, UnknownStatement<SemVer>, EffectiveStatement<SemVer, UnknownStatement<SemVer>>> {
38 public SemanticVersionSupport() {
39 super(SupportedExtensionsMapping.SEMANTIC_VERSION);
43 public SemVer parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
44 return SemVer.valueOf(value) ;
48 public void onLinkageDeclared(final StmtContext.Mutable<SemVer,UnknownStatement<SemVer>,EffectiveStatement<SemVer,UnknownStatement<SemVer>>> stmt) {
49 stmt.addToNs(SemanticVersionNamespace.class, stmt.getParentContext(), stmt.getStatementArgument());
53 public void onFullDefinitionDeclared(
54 final Mutable<SemVer, UnknownStatement<SemVer>, EffectiveStatement<SemVer, UnknownStatement<SemVer>>> stmt)
55 throws SourceException {
56 getSubstatementValidator().validate(stmt);
60 public UnknownStatement<SemVer> createDeclared(
61 final StmtContext<SemVer, UnknownStatement<SemVer>, ?> ctx) {
62 return new SemanticVersionStatementImpl(ctx);
66 public EffectiveStatement<SemVer, UnknownStatement<SemVer>> createEffective(
67 final StmtContext<SemVer, UnknownStatement<SemVer>, EffectiveStatement<SemVer, UnknownStatement<SemVer>>> ctx) {
68 return new SemanticVersionEffectiveStatementImpl(ctx);
72 protected SubstatementValidator getSubstatementValidator() {
73 return SUBSTATEMENT_VALIDATOR;
78 public SemVer getArgument() {