-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.RefineEffectiveStatementImpl;
+import static org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator.MAX;
+import javax.annotation.Nullable;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.RefineStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import javax.annotation.Nullable;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.RefineEffectiveStatementImpl;
public class RefineStatementImpl extends AbstractDeclaredStatement<SchemaNodeIdentifier> implements RefineStatement {
+ private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
+ .REFINE)
+ .add(Rfc6020Mapping.DEFAULT, 0, 1)
+ .add(Rfc6020Mapping.DESCRIPTION, 0, 1)
+ .add(Rfc6020Mapping.REFERENCE, 0, 1)
+ .add(Rfc6020Mapping.CONFIG, 0, 1)
+ .add(Rfc6020Mapping.MANDATORY, 0, 1)
+ .add(Rfc6020Mapping.PRESENCE, 0, 1)
+ .add(Rfc6020Mapping.MUST, 0, MAX)
+ .add(Rfc6020Mapping.MIN_ELEMENTS, 0, 1)
+ .add(Rfc6020Mapping.MAX_ELEMENTS, 0, 1)
+ .build();
- protected RefineStatementImpl(
- StmtContext<SchemaNodeIdentifier, RefineStatement, ?> context) {
+ protected RefineStatementImpl(final StmtContext<SchemaNodeIdentifier, RefineStatement, ?> context) {
super(context);
}
}
@Override
- public SchemaNodeIdentifier parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
- return SchemaNodeIdentifier.create(Utils.parseXPath(ctx, value), Utils.isXPathAbsolute(value));
+ public SchemaNodeIdentifier parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+ return Utils.nodeIdentifierFromPath(ctx, value);
}
@Override
- public RefineStatement createDeclared(StmtContext<SchemaNodeIdentifier, RefineStatement, ?> ctx) {
+ public RefineStatement createDeclared(final StmtContext<SchemaNodeIdentifier, RefineStatement, ?> ctx) {
return new RefineStatementImpl(ctx);
}
@Override
- public EffectiveStatement<SchemaNodeIdentifier, RefineStatement> createEffective(StmtContext<SchemaNodeIdentifier, RefineStatement, EffectiveStatement<SchemaNodeIdentifier, RefineStatement>> ctx) {
+ public EffectiveStatement<SchemaNodeIdentifier, RefineStatement> createEffective(
+ final StmtContext<SchemaNodeIdentifier, RefineStatement, EffectiveStatement<SchemaNodeIdentifier, RefineStatement>> ctx) {
return new RefineEffectiveStatementImpl(ctx);
}
+
+ @Override
+ public void onFullDefinitionDeclared(StmtContext.Mutable<SchemaNodeIdentifier, RefineStatement,
+ EffectiveStatement<SchemaNodeIdentifier, RefineStatement>> stmt) throws SourceException {
+ super.onFullDefinitionDeclared(stmt);
+ SUBSTATEMENT_VALIDATOR.validate(stmt);
+ }
}
@Override