-/**
+/*
* Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
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;
+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.meta.StmtContextUtils;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.KeyEffectiveStatementImpl;
public class KeyStatementImpl extends AbstractDeclaredStatement<Collection<SchemaNodeIdentifier>> implements
KeyStatement {
+ private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(Rfc6020Mapping
+ .KEY)
+ .build();
protected KeyStatementImpl(final StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, ?> context) {
super(context);
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);
// 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);
+ Preconditions.checkArgument(ret.size() == tokens, "Key argument '%s' contains duplicates. At %s", value,
+ ctx.getStatementSourceReference());
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);
+ }
+ }
}