2 * Copyright (c) 2015 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.spi.meta;
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.yangtools.yang.common.QName;
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.meta.StatementDefinition;
15 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
19 * Class providing necessary support for processing YANG statement.
21 * This class is intended to be subclassed by developers, which want to
22 * introduce support of statement to parser.
27 * Declared Statement representation
29 * Effective Statement representation
31 public abstract class AbstractStatementSupport<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
32 implements StatementDefinition, StatementFactory<A, D, E>, StatementSupport<A, D, E> {
34 private final StatementDefinition type;
36 protected AbstractStatementSupport(StatementDefinition publicDefinition) {
37 Preconditions.checkArgument(publicDefinition != this);
38 this.type = Preconditions.checkNotNull(publicDefinition);
42 public final QName getStatementName() {
43 return type.getStatementName();
47 public final QName getArgumentName() {
48 return type.getArgumentName();
52 public final Class<? extends DeclaredStatement<?>> getDeclaredRepresentationClass() {
53 return type.getDeclaredRepresentationClass();
57 public final Class<? extends EffectiveStatement<?,?>> getEffectiveRepresentationClass() {
58 return type.getEffectiveRepresentationClass();
62 public final StatementDefinition getPublicView() {
67 public abstract A parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException;
70 public void onStatementAdded(StmtContext.Mutable<A, D, E> stmt) {
71 // NOOP for most implementations
78 * Subclasses of this class may override this method to perform actions on
79 * this event or register modification action using
80 * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}.
84 public void onLinkageDeclared(StmtContext.Mutable<A, D, E> stmt) throws SourceException {
85 // NOOP for most implementations
92 * Subclasses of this class may override this method to perform actions on
93 * this event or register modification action using
94 * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}.
98 public void onStatementDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws SourceException {
99 // NOOP for most implementations
106 * Subclasses of this class may override this method to perform actions on
107 * this event or register modification action using
108 * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}.
112 public void onFullDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws SourceException {
113 // NOOP for most implementations