/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.yangtools.yang.parser.spi.meta; import com.google.common.base.Preconditions; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; /** * * Class providing necessary support for processing YANG statement. * * This class is intended to be subclassed by developers, which want to * introduce support of statement to parser. * * @param * Argument type * @param * Declared Statement representation * @param * Effective Statement representation */ public abstract class AbstractStatementSupport, E extends EffectiveStatement> implements StatementDefinition, StatementFactory, StatementSupport { private final StatementDefinition type; protected AbstractStatementSupport(StatementDefinition publicDefinition) { Preconditions.checkArgument(publicDefinition != this); this.type = Preconditions.checkNotNull(publicDefinition); } @Override public final QName getStatementName() { return type.getStatementName(); } @Override public final QName getArgumentName() { return type.getArgumentName(); } @Override public final Class> getDeclaredRepresentationClass() { return type.getDeclaredRepresentationClass(); } @Override public final Class> getEffectiveRepresentationClass() { return type.getEffectiveRepresentationClass(); } @Override public final StatementDefinition getPublicView() { return type; } @Override public abstract A parseArgumentValue(StmtContext ctx, String value) throws SourceException; @Override public void onStatementAdded(StmtContext.Mutable stmt) { // NOOP for most implementations }; /** * * {@inheritDoc} * * Subclasses of this class may override this method to perform actions on * this event or register modification action using * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}. * */ @Override public void onLinkageDeclared(StmtContext.Mutable stmt) throws InferenceException, SourceException { // NOOP for most implementations } /** * * {@inheritDoc} * * Subclasses of this class may override this method to perform actions on * this event or register modification action using * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}. * */ @Override public void onStatementDefinitionDeclared(StmtContext.Mutable stmt) throws InferenceException, SourceException { // NOOP for most implementations } /** * * {@inheritDoc} * * Subclasses of this class may override this method to perform actions on * this event or register modification action using * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}. * */ @Override public void onFullDefinitionDeclared(StmtContext.Mutable stmt) throws InferenceException, SourceException { // NOOP for most implementations } }