Migrate coerceStatementArgument() callers
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / augment / AugmentEffectiveStatementImpl.java
index b4258d8e8fc6ef954555b610d138692130cdf700..159b69e5b501a7a6efb933777964a4bf3aa88779 100644 (file)
@@ -7,18 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.augment;
 
-import static com.google.common.base.Verify.verifyNotNull;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.ImmutableList;
-import java.net.URI;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.NamespaceRevisionAware;
+import org.opendaylight.yangtools.yang.model.api.QNameModuleAware;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.AugmentEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement;
@@ -31,19 +28,21 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMix
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 
 final class AugmentEffectiveStatementImpl extends DefaultDataNodeContainer<SchemaNodeIdentifier, AugmentStatement>
-        implements AugmentEffectiveStatement, AugmentationSchemaNode, NamespaceRevisionAware,
+        implements AugmentEffectiveStatement, AugmentationSchemaNode, QNameModuleAware,
             DocumentedNodeMixin.WithStatus<SchemaNodeIdentifier, AugmentStatement>,
             ActionNodeContainerMixin<SchemaNodeIdentifier, AugmentStatement>,
             NotificationNodeContainerMixin<SchemaNodeIdentifier, AugmentStatement>,
             WhenConditionMixin<SchemaNodeIdentifier, AugmentStatement> {
     private final @Nullable AugmentationSchemaNode original;
+    private final @NonNull SchemaNodeIdentifier argument;
     private final @NonNull QNameModule rootModuleQName;
     private final int flags;
 
-    AugmentEffectiveStatementImpl(final AugmentStatement declared, final int flags, final QNameModule rootModuleQName,
-            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final StatementSourceReference ref,
-            final @Nullable AugmentationSchemaNode original) {
+    AugmentEffectiveStatementImpl(final AugmentStatement declared, final SchemaNodeIdentifier argument, final int flags,
+            final QNameModule rootModuleQName, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
+            final StatementSourceReference ref, final @Nullable AugmentationSchemaNode original) {
         super(declared, ref, substatements);
+        this.argument = requireNonNull(argument);
         this.rootModuleQName = requireNonNull(rootModuleQName);
         this.flags = flags;
         this.original = original;
@@ -51,8 +50,7 @@ final class AugmentEffectiveStatementImpl extends DefaultDataNodeContainer<Schem
 
     @Override
     public @NonNull SchemaNodeIdentifier argument() {
-        // FIXME: YANGTOOLS-1065: this is not okay, as this can actually have different namespaces
-        return verifyNotNull(getDeclared().argument());
+        return argument;
     }
 
     @Override
@@ -60,24 +58,19 @@ final class AugmentEffectiveStatementImpl extends DefaultDataNodeContainer<Schem
         return Optional.ofNullable(this.original);
     }
 
-    @Override
-    public SchemaNodeIdentifier getTargetPath() {
-        return argument();
-    }
-
     @Override
     public int flags() {
         return flags;
     }
 
     @Override
-    public URI getNamespace() {
-        return rootModuleQName.getNamespace();
+    public QNameModule getQNameModule() {
+        return rootModuleQName;
     }
 
     @Override
-    public Optional<Revision> getRevision() {
-        return rootModuleQName.getRevision();
+    public AugmentEffectiveStatement asEffectiveStatement() {
+        return this;
     }
 
     @Override