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.stmt.rfc6020.effective.SemanticVersionEffectiveStatementImpl;
22 public final class SemanticVersionStatementImpl extends AbstractDeclaredStatement<SemVer> implements
23 UnknownStatement<SemVer> {
24 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
25 SupportedExtensionsMapping.SEMANTIC_VERSION).build();
27 SemanticVersionStatementImpl(
28 final StmtContext<SemVer, UnknownStatement<SemVer>, ?> context) {
32 public static class SemanticVersionSupport
34 AbstractStatementSupport<SemVer, UnknownStatement<SemVer>, EffectiveStatement<SemVer, UnknownStatement<SemVer>>> {
36 public SemanticVersionSupport() {
37 super(SupportedExtensionsMapping.SEMANTIC_VERSION);
41 public SemVer parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
42 return SemVer.valueOf(value) ;
46 public void onLinkageDeclared(final StmtContext.Mutable<SemVer,UnknownStatement<SemVer>,EffectiveStatement<SemVer,UnknownStatement<SemVer>>> stmt) {
47 stmt.addToNs(SemanticVersionNamespace.class, stmt.getParentContext(), stmt.getStatementArgument());
51 public UnknownStatement<SemVer> createDeclared(
52 final StmtContext<SemVer, UnknownStatement<SemVer>, ?> ctx) {
53 return new SemanticVersionStatementImpl(ctx);
57 public EffectiveStatement<SemVer, UnknownStatement<SemVer>> createEffective(
58 final StmtContext<SemVer, UnknownStatement<SemVer>, EffectiveStatement<SemVer, UnknownStatement<SemVer>>> ctx) {
59 return new SemanticVersionEffectiveStatementImpl(ctx);
63 protected SubstatementValidator getSubstatementValidator() {
64 return SUBSTATEMENT_VALIDATOR;
69 public SemVer getArgument() {