package org.opendaylight.yangtools.yang.parser.spi.meta;
import com.google.common.base.Preconditions;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
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;
+import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
/**
*
private final StatementDefinition type;
- protected AbstractStatementSupport(StatementDefinition publicDefinition) {
+ protected AbstractStatementSupport(final StatementDefinition publicDefinition) {
Preconditions.checkArgument(publicDefinition != this);
this.type = Preconditions.checkNotNull(publicDefinition);
}
+ @Nonnull
@Override
public final QName getStatementName() {
return type.getStatementName();
return type.getArgumentName();
}
+ @Nonnull
@Override
public final Class<? extends DeclaredStatement<?>> getDeclaredRepresentationClass() {
return type.getDeclaredRepresentationClass();
}
+ @Nonnull
@Override
- public final Class<? extends DeclaredStatement<?>> getEffectiveRepresentationClass() {
+ public final Class<? extends EffectiveStatement<?,?>> getEffectiveRepresentationClass() {
return type.getEffectiveRepresentationClass();
}
}
@Override
- public abstract A parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException;
+ public void onStatementAdded(final StmtContext.Mutable<A, D, E> 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 onStatementAdded(StmtContext.Mutable<A, D, E> stmt) {
+ public void onPreLinkageDeclared(final StmtContext.Mutable<A, D, E> 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<A, D, E> stmt) throws InferenceException, SourceException {
+ public void onLinkageDeclared(final StmtContext.Mutable<A, D, E> 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 onStatementDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws InferenceException,
- SourceException {
+ public void onStatementDefinitionDeclared(final StmtContext.Mutable<A, D, E> 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 onFullDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt) throws InferenceException, SourceException {
- // NOOP for most implementations
+ public void onFullDefinitionDeclared(final StmtContext.Mutable<A, D, E> stmt) {
+ final SubstatementValidator validator = getSubstatementValidator();
+ if (validator != null) {
+ validator.validate(stmt);
+ }
}
+ @Override
+ public boolean isArgumentYinElement() {
+ return getPublicView().isArgumentYinElement();
+ }
+
+ /**
+ * Returns corresponding substatement validator of a statement support
+ *
+ * @return substatement validator or null, if substatement validator is not
+ * defined
+ */
+ @Nullable
+ protected abstract SubstatementValidator getSubstatementValidator();
}