-/**
+/*
* 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 javax.annotation.Nonnull;
+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.RequireInstanceStatement;
-
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.InstanceIdentifierSpecification;
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.model.api.Rfc6020Mapping;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.InstanceIdentifierSpecificationEffectiveStatementImpl;
-public class InstanceIdentifierSpecificationImpl extends
- AbstractDeclaredStatement<String> implements
- TypeStatement.InstanceIdentifierSpecification {
+public class InstanceIdentifierSpecificationImpl extends AbstractDeclaredStatement<String>
+ implements InstanceIdentifierSpecification {
+ private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
+ .TYPE)
+ .addOptional(YangStmtMapping.REQUIRE_INSTANCE)
+ .build();
- protected InstanceIdentifierSpecificationImpl(
- StmtContext<String, TypeStatement.InstanceIdentifierSpecification, ?> context) {
- super(context);
+ protected InstanceIdentifierSpecificationImpl(final StmtContext<String, InstanceIdentifierSpecification, ?> ctx) {
+ super(ctx);
}
- public static class Definition
- extends
- AbstractStatementSupport<String, TypeStatement.InstanceIdentifierSpecification, EffectiveStatement<String, TypeStatement.InstanceIdentifierSpecification>> {
+ public static class Definition extends AbstractStatementSupport<String, InstanceIdentifierSpecification,
+ EffectiveStatement<String, InstanceIdentifierSpecification>> {
public Definition() {
- super(Rfc6020Mapping.REQUIRE_INSTANCE);
+ super(YangStmtMapping.TYPE);
}
@Override
- public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
- throws SourceException {
+ public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
return value;
}
@Override
- public TypeStatement.InstanceIdentifierSpecification createDeclared(
- StmtContext<String, TypeStatement.InstanceIdentifierSpecification, ?> ctx) {
+ public InstanceIdentifierSpecification createDeclared(
+ final StmtContext<String, InstanceIdentifierSpecification, ?> ctx) {
return new InstanceIdentifierSpecificationImpl(ctx);
}
@Override
- public EffectiveStatement<String, TypeStatement.InstanceIdentifierSpecification> createEffective(
- StmtContext<String, TypeStatement.InstanceIdentifierSpecification, EffectiveStatement<String, TypeStatement.InstanceIdentifierSpecification>> ctx) {
- throw new UnsupportedOperationException();
+ public EffectiveStatement<String, InstanceIdentifierSpecification> createEffective(
+ final StmtContext<String, InstanceIdentifierSpecification,
+ EffectiveStatement<String, InstanceIdentifierSpecification>> ctx) {
+ return new InstanceIdentifierSpecificationEffectiveStatementImpl(ctx);
+ }
+
+ @Override
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;
}
}
+ @Nonnull
@Override
public String getName() {
return argument();
public RequireInstanceStatement getRequireInstance() {
return firstDeclared(RequireInstanceStatement.class);
}
-
}