Fixup collections return implementations
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / deviation / DeviationStatementSupport.java
index bd4e994aadb82dc39ad48b607a8a0f18b20abd62..1ac7a08ad1da59c4b0bf88d0b370f4d4b444d67a 100644 (file)
@@ -8,13 +8,14 @@
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.deviation;
 
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 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.DeviationEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DeviationStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
@@ -24,7 +25,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName;
 
 public final class DeviationStatementSupport
-        extends BaseStatementSupport<SchemaNodeIdentifier, DeviationStatement, DeviationEffectiveStatement> {
+        extends BaseStatementSupport<Absolute, DeviationStatement, DeviationEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(YangStmtMapping
         .DEVIATION)
         .addOptional(YangStmtMapping.DESCRIPTION)
@@ -42,16 +43,17 @@ public final class DeviationStatementSupport
     }
 
     @Override
-    public SchemaNodeIdentifier parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
-        return ArgumentUtils.nodeIdentifierFromPath(ctx, value);
+    public Absolute parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+        return ArgumentUtils.parseAbsoluteSchemaNodeIdentifier(ctx, value);
     }
 
     @Override
     public void onFullDefinitionDeclared(
-            final Mutable<SchemaNodeIdentifier, DeviationStatement, DeviationEffectiveStatement> ctx) {
+            final Mutable<Absolute, DeviationStatement, DeviationEffectiveStatement> ctx) {
         final QNameModule currentModule = ctx.getFromNamespace(ModuleCtxToModuleQName.class,
                 ctx.getRoot());
-        final QNameModule targetModule = ctx.coerceStatementArgument().getLastComponent().getModule();
+        final QNameModule targetModule = Iterables.getLast(ctx.coerceStatementArgument().getNodeIdentifiers())
+                .getModule();
 
         if (currentModule.equals(targetModule)) {
             throw new InferenceException(ctx.getStatementSourceReference(),
@@ -65,27 +67,27 @@ public final class DeviationStatementSupport
     }
 
     @Override
-    protected DeviationStatement createDeclared(final StmtContext<SchemaNodeIdentifier, DeviationStatement, ?> ctx,
+    protected DeviationStatement createDeclared(final StmtContext<Absolute, DeviationStatement, ?> ctx,
             final ImmutableList<? extends DeclaredStatement<?>> substatements) {
-        return new DeviationStatementImpl(ctx, substatements);
+        return new DeviationStatementImpl(ctx.coerceRawStatementArgument(), ctx.coerceStatementArgument(),
+            substatements);
     }
 
     @Override
-    protected DeviationStatement createEmptyDeclared(
-            final StmtContext<SchemaNodeIdentifier, DeviationStatement, ?> ctx) {
-        return new DeviationStatementImpl(ctx, ImmutableList.of());
+    protected DeviationStatement createEmptyDeclared(final StmtContext<Absolute, DeviationStatement, ?> ctx) {
+        return createDeclared(ctx, ImmutableList.of());
     }
 
     @Override
     protected DeviationEffectiveStatement createEffective(
-            final StmtContext<SchemaNodeIdentifier, DeviationStatement, DeviationEffectiveStatement> ctx,
+            final StmtContext<Absolute, DeviationStatement, DeviationEffectiveStatement> ctx,
             final DeviationStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         return new DeviationEffectiveStatementImpl(declared, substatements);
     }
 
     @Override
     protected DeviationEffectiveStatement createEmptyEffective(
-            final StmtContext<SchemaNodeIdentifier, DeviationStatement, DeviationEffectiveStatement> ctx,
+            final StmtContext<Absolute, DeviationStatement, DeviationEffectiveStatement> ctx,
             final DeviationStatement declared) {
         return new DeviationEffectiveStatementImpl(declared, ImmutableList.of());
     }