/*
- * Copyright (c) 2019 PANTHEON.tech s.r.o. and others. All rights reserved.
+ * Copyright (c) 2019 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,
import com.google.common.collect.ImmutableList;
import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.rfc8528.model.api.MountPointEffectiveStatement;
-import org.opendaylight.yangtools.rfc8528.model.api.MountPointSchemaNode;
import org.opendaylight.yangtools.rfc8528.model.api.MountPointStatement;
import org.opendaylight.yangtools.rfc8528.model.api.SchemaMountStatements;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.model.api.SchemaNodeDefaults;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
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.meta.StatementDefinition;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractDeclaredStatement.WithQNameArgument.WithSubstatements;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.UnknownEffectiveStatementBase;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractQNameStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.SchemaPathSupport;
}
}
- private static final class Effective extends UnknownEffectiveStatementBase<QName, MountPointStatement>
- implements MountPointEffectiveStatement, MountPointSchemaNode {
-
- private final @Nullable SchemaPath path;
-
- Effective(final Current<QName, MountPointStatement> stmt,
- final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- super(stmt, substatements);
- path = SchemaPathSupport.wrap(stmt.getEffectiveParent().getSchemaPath().createChild(argument()));
- }
-
- @Override
- public QName getQName() {
- return path.getLastComponent();
- }
-
- @Override
- @Deprecated
- public SchemaPath getPath() {
- return SchemaNodeDefaults.throwUnsupportedIfNull(this, path);
- }
-
- @Override
- public MountPointEffectiveStatement asEffectiveStatement() {
- return this;
- }
- }
-
private static final MountPointStatementSupport INSTANCE = new MountPointStatementSupport(
SchemaMountStatements.MOUNT_POINT);
private final SubstatementValidator validator;
MountPointStatementSupport(final StatementDefinition definition) {
- super(definition, StatementPolicy.legacyDeclaredCopy());
+ super(definition, StatementPolicy.copyDeclared((copy, current, substatements) ->
+ copy.getArgument().equals(current.getArgument())
+ // Implied by UnknownSchemaNode
+ && copy.history().isAugmenting() == current.history().isAugmenting()
+ && copy.history().isAddedByUses() == current.history().isAddedByUses()
+ && copy.equalParentPath(current)));
this.validator = SubstatementValidator.builder(definition)
.addOptional(YangStmtMapping.CONFIG)
.addOptional(YangStmtMapping.DESCRIPTION)
return INSTANCE;
}
+ // FIXME: these two methods are not quite right. RFC8528 states that:
+ //
+ // If a mount point is defined within a grouping, its label is
+ // bound to the module where the grouping is used.
+ //
+ // We are not doing exactly that, in that we can end up rebinding the argument through 'augment', I think.
@Override
public QName parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
return StmtContextUtils.parseIdentifier(ctx, value);
@Override
protected MountPointEffectiveStatement createEffective(final Current<QName, MountPointStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new Effective(stmt, substatements);
+ return new MountPointEffectiveStatementImpl(stmt, substatements,
+ SchemaPathSupport.wrap(stmt.getEffectiveParent().getSchemaPath().createChild(stmt.getArgument())));
}
}