Fix somar complaints in equals methods
[yangtools.git] / yang / rfc6643-parser-support / src / main / java / org / opendaylight / yangtools / rfc6643 / parser / SubIdEffectiveStatementImpl.java
index 650293f299c5854674314ae267ba3aa7c6d8c963..7384cceb11ae99d3233d009d2749fa9b3e85dd0a 100644 (file)
@@ -14,25 +14,22 @@ import org.opendaylight.yangtools.rfc6643.model.api.SubIdSchemaNode;
 import org.opendaylight.yangtools.rfc6643.model.api.SubIdStatement;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.model.api.SchemaNodeDefaults;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.UnknownEffectiveStatementBase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SchemaPathSupport;
 
 final class SubIdEffectiveStatementImpl extends UnknownEffectiveStatementBase<Uint32, SubIdStatement>
         implements SubIdEffectiveStatement, SubIdSchemaNode {
 
     private final SchemaPath path;
 
-    SubIdEffectiveStatementImpl(final StmtContext<Uint32, SubIdStatement, ?> ctx,
+    SubIdEffectiveStatementImpl(final Current<Uint32, SubIdStatement> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
-        super(ctx, substatements);
-        path = ctx.getParentContext().getSchemaPath().get().createChild(getNodeType());
-    }
-
-    @Override
-    public Uint32 getArgument() {
-        return argument();
+        super(stmt, substatements);
+        path = SchemaPathSupport.wrap(stmt.getEffectiveParent().getSchemaPath().createChild(getNodeType()));
     }
 
     @Override
@@ -41,8 +38,14 @@ final class SubIdEffectiveStatementImpl extends UnknownEffectiveStatementBase<Ui
     }
 
     @Override
+    @Deprecated
     public SchemaPath getPath() {
-        return path;
+        return SchemaNodeDefaults.throwUnsupportedIfNull(this, path);
+    }
+
+    @Override
+    public SubIdEffectiveStatement asEffectiveStatement() {
+        return this;
     }
 
     @Override
@@ -55,22 +58,11 @@ final class SubIdEffectiveStatementImpl extends UnknownEffectiveStatementBase<Ui
         if (this == obj) {
             return true;
         }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
+        if (!(obj instanceof SubIdEffectiveStatementImpl)) {
             return false;
         }
         final SubIdEffectiveStatementImpl other = (SubIdEffectiveStatementImpl) obj;
-        if (!Objects.equals(path, other.path)) {
-            return false;
-        }
-        if (!Objects.equals(getNodeType(), other.getNodeType())) {
-            return false;
-        }
-        if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
-            return false;
-        }
-        return true;
+        return Objects.equals(getNodeType(), other.getNodeType())
+            && Objects.equals(getNodeParameter(), other.getNodeParameter()) && Objects.equals(path, other.path);
     }
 }