package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.augment;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.List;
-import java.util.Objects;
import java.util.regex.Pattern;
+import java.util.stream.Stream;
import org.opendaylight.yangtools.yang.common.Empty;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
import org.opendaylight.yangtools.yang.model.spi.meta.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
-import org.opendaylight.yangtools.yang.parser.spi.SchemaTreeNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.ParserNamespaces;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.BoundStmtCtx;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
AbstractAugmentStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) {
super(YangStmtMapping.AUGMENT, StatementPolicy.copyDeclared(
- (copy, current, substatements) ->
- copy.getArgument().equals(current.getArgument())
- && copy.moduleName().getModule().equals(current.moduleName().getModule())
- && Objects.equals(copy.original(), current.original())
- ), config, validator);
+ (copy, current, substatements) -> copy.getArgument().equals(current.getArgument())),
+ config, validator);
}
@Override
"Augment argument \'%s\' is not valid, it can be only absolute path; or descendant if used in uses", value);
// As per:
- // https://tools.ietf.org/html/rfc6020#section-7.15
- // https://tools.ietf.org/html/rfc7950#section-7.17
+ // https://www.rfc-editor.org/rfc/rfc6020#section-7.15
+ // https://www.rfc-editor.org/rfc/rfc7950#section-7.17
//
// The argument is either Absolute or Descendant based on whether the statement is declared within a 'uses'
// statement. The mechanics differs wildly between the two cases, so let's start by ensuring our argument
final ModelActionBuilder augmentAction = augmentNode.newInferenceAction(ModelProcessingPhase.EFFECTIVE_MODEL);
augmentAction.requiresCtx(augmentNode, ModelProcessingPhase.EFFECTIVE_MODEL);
final Prerequisite<Mutable<?, ?, EffectiveStatement<?, ?>>> target = augmentAction.mutatesEffectiveCtxPath(
- getSearchRoot(augmentNode), SchemaTreeNamespace.class, augmentNode.getArgument().getNodeIdentifiers());
+ getSearchRoot(augmentNode), ParserNamespaces.schemaTree(), augmentNode.getArgument().getNodeIdentifiers());
augmentAction.apply(new AugmentInferenceAction(this, augmentNode, target));
}
}
@Override
- protected final List<? extends StmtContext<?, ?, ?>> statementsToBuild(
+ protected final Stream<? extends StmtContext<?, ?, ?>> statementsToBuild(
final Current<SchemaNodeIdentifier, AugmentStatement> stmt,
- final List<? extends StmtContext<?, ?, ?>> substatements) {
+ final Stream<? extends StmtContext<?, ?, ?>> substatements) {
// Pick up the marker left by onFullDefinitionDeclared() inference action. If it is present we need to pass our
// children through target's implicit wrapping.
- final var implicitDef = stmt.getFromNamespace(AugmentImplicitHandlingNamespace.class, Empty.value());
+ final var implicitDef = stmt.namespaceItem(AugmentImplicitHandlingNamespace.INSTANCE, Empty.value());
return implicitDef == null ? substatements
- : Lists.transform(substatements, subCtx -> implicitDef.wrapWithImplicit(subCtx));
+ : substatements.map(subCtx -> implicitDef.wrapWithImplicit(subCtx));
}
@Override
- @SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "Cast of original(), should be always safe")
protected final AugmentEffectiveStatement createEffective(
final Current<SchemaNodeIdentifier, AugmentStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
.toFlags();
try {
- return EffectiveStatements.createAugment(stmt.declared(), stmt.getArgument(), flags,
- stmt.moduleName().getModule(), substatements, (AugmentationSchemaNode) stmt.original());
+ return EffectiveStatements.createAugment(stmt.declared(), stmt.getArgument(), flags, substatements);
} catch (SubstatementIndexingException e) {
throw new SourceException(e.getMessage(), stmt, e);
}