/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type;
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.rfc7950.stmt.AbstractDeclaredStatement.WithRawStringArgument;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-final class InstanceIdentifierSpecificationImpl extends AbstractDeclaredStatement<String>
- implements InstanceIdentifierSpecification {
- InstanceIdentifierSpecificationImpl(final StmtContext<String, InstanceIdentifierSpecification, ?> ctx) {
+final class EmptyIdentifierSpecification extends WithRawStringArgument implements InstanceIdentifierSpecification {
+ EmptyIdentifierSpecification(final StmtContext<String, ?, ?> ctx) {
super(ctx);
}
}
+++ /dev/null
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.InstanceIdentifierSpecification;
-import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
-import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
-import org.opendaylight.yangtools.yang.model.util.type.InstanceIdentifierTypeBuilder;
-import org.opendaylight.yangtools.yang.model.util.type.RestrictedTypes;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-
-final class InstanceIdentifierSpecificationEffectiveStatement
- extends DeclaredEffectiveStatementBase<String, InstanceIdentifierSpecification>
- implements TypeEffectiveStatement<InstanceIdentifierSpecification> {
-
- private final @NonNull InstanceIdentifierTypeDefinition typeDefinition;
-
- InstanceIdentifierSpecificationEffectiveStatement(final StmtContext<String,
- InstanceIdentifierSpecification, EffectiveStatement<String, InstanceIdentifierSpecification>> ctx) {
- super(ctx);
-
- final InstanceIdentifierTypeBuilder builder = RestrictedTypes.newInstanceIdentifierBuilder(
- BaseTypes.instanceIdentifierType(), ctx.getSchemaPath().get());
-
- for (EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
- if (stmt instanceof RequireInstanceEffectiveStatement) {
- builder.setRequireInstance(((RequireInstanceEffectiveStatement)stmt).argument());
- }
- if (stmt instanceof UnknownSchemaNode) {
- builder.addUnknownSchemaNode((UnknownSchemaNode)stmt);
- }
- }
-
- typeDefinition = builder.build();
- }
-
- @Override
- public InstanceIdentifierTypeDefinition getTypeDefinition() {
- return typeDefinition;
- }
-}
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type;
+import com.google.common.collect.ImmutableList;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+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.stmt.RequireInstanceEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.InstanceIdentifierSpecification;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
+import org.opendaylight.yangtools.yang.model.util.type.InstanceIdentifierTypeBuilder;
+import org.opendaylight.yangtools.yang.model.util.type.RestrictedTypes;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
-final class InstanceIdentifierSpecificationSupport extends AbstractStatementSupport<String,
+final class InstanceIdentifierSpecificationSupport extends BaseStatementSupport<String,
InstanceIdentifierSpecification, EffectiveStatement<String, InstanceIdentifierSpecification>> {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
YangStmtMapping.TYPE)
}
@Override
- public InstanceIdentifierSpecification createDeclared(
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;
+ }
+
+ @Override
+ protected InstanceIdentifierSpecification createDeclared(
+ final StmtContext<String, InstanceIdentifierSpecification, ?> ctx,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ return new RegularInstanceIdentifierSpecification(ctx, substatements);
+ }
+
+ @Override
+ protected InstanceIdentifierSpecification createEmptyDeclared(
final StmtContext<String, InstanceIdentifierSpecification, ?> ctx) {
- return new InstanceIdentifierSpecificationImpl(ctx);
+ return new EmptyIdentifierSpecification(ctx);
}
@Override
- public EffectiveStatement<String, InstanceIdentifierSpecification> createEffective(
+ protected EffectiveStatement<String, InstanceIdentifierSpecification> createEffective(
final StmtContext<String, InstanceIdentifierSpecification,
- EffectiveStatement<String, InstanceIdentifierSpecification>> ctx) {
- return new InstanceIdentifierSpecificationEffectiveStatement(ctx);
+ EffectiveStatement<String, InstanceIdentifierSpecification>> ctx,
+ final InstanceIdentifierSpecification declared,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ final InstanceIdentifierTypeBuilder builder = RestrictedTypes.newInstanceIdentifierBuilder(
+ BaseTypes.instanceIdentifierType(), ctx.getSchemaPath().get());
+
+ for (EffectiveStatement<?, ?> stmt : substatements) {
+ if (stmt instanceof RequireInstanceEffectiveStatement) {
+ builder.setRequireInstance(((RequireInstanceEffectiveStatement)stmt).argument());
+ }
+ }
+
+ return new TypeEffectiveStatementImpl<>(declared, substatements, builder);
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
- return SUBSTATEMENT_VALIDATOR;
+ protected EffectiveStatement<String, InstanceIdentifierSpecification> createEmptyEffective(
+ final StmtContext<String, InstanceIdentifierSpecification,
+ EffectiveStatement<String, InstanceIdentifierSpecification>> ctx,
+ final InstanceIdentifierSpecification declared) {
+ // TODO: we could do better here, but its really splitting hairs
+ return createEffective(ctx, declared, ImmutableList.of());
}
}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type;
+
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.InstanceIdentifierSpecification;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredStatement.WithRawStringArgument.WithSubstatements;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+final class RegularInstanceIdentifierSpecification extends WithSubstatements
+ implements InstanceIdentifierSpecification {
+ RegularInstanceIdentifierSpecification(final StmtContext<String, ?, ?> ctx,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ super(ctx, substatements);
+ }
+}