*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import java.util.Collection;
-import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.KeyStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
public class KeyStatementImpl extends AbstractDeclaredStatement<Collection<SchemaNodeIdentifier>> implements
KeyStatement {
- private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
+ private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
.KEY)
.build();
public static class Definition
extends
- AbstractStatementSupport<Collection<SchemaNodeIdentifier>, KeyStatement, EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> {
+ AbstractStatementSupport<Collection<SchemaNodeIdentifier>, KeyStatement,
+ EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> {
public Definition() {
- super(Rfc6020Mapping.KEY);
+ super(YangStmtMapping.KEY);
}
@Override
// Throws NPE on nulls, retains first inserted value, cannot be modified
final Collection<SchemaNodeIdentifier> ret = builder.build();
-
- Preconditions.checkArgument(ret.size() == tokens, "Key argument '%s' contains duplicates", value);
+ SourceException.throwIf(ret.size() != tokens, ctx.getStatementSourceReference(),
+ "Key argument '%s' contains duplicates", value);
return ret;
}
@Override
public EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement> createEffective(
- final StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> ctx) {
+ final StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement,
+ EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> ctx) {
return new KeyEffectiveStatementImpl(ctx);
}
@Override
- public void onFullDefinitionDeclared(StmtContext.Mutable<Collection<SchemaNodeIdentifier>, KeyStatement,
- EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> stmt) throws SourceException {
- super.onFullDefinitionDeclared(stmt);
- SUBSTATEMENT_VALIDATOR.validate(stmt);
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;
}
}
}