Allow derived context to be reused
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / notification / AbstractNotificationStatementSupport.java
index b46b754977297b236a55497689f32c8fa6ef7d11..51ab5b62c26834860cf6fd0a0ea8e7ef59750cdf 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseSchemaTreeStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
@@ -23,7 +24,7 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 abstract class AbstractNotificationStatementSupport
         extends BaseSchemaTreeStatementSupport<NotificationStatement, NotificationEffectiveStatement> {
     AbstractNotificationStatementSupport() {
-        super(YangStmtMapping.NOTIFICATION);
+        super(YangStmtMapping.NOTIFICATION, uninstantiatedPolicy());
     }
 
     @Override
@@ -40,15 +41,19 @@ abstract class AbstractNotificationStatementSupport
     @Override
     protected final NotificationEffectiveStatement createEffective(final Current<QName, NotificationStatement> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
-        checkEffective(stmt);
-
         try {
             return new NotificationEffectiveStatementImpl(stmt.declared(), substatements,
-                historyAndStatusFlags(stmt.history(), substatements), stmt.wrapSchemaPath());
+                EffectiveStatementMixins.historyAndStatusFlags(stmt.history(), substatements), stmt.wrapSchemaPath());
         } catch (SubstatementIndexingException e) {
-            throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+            throw new SourceException(e.getMessage(), stmt, e);
         }
     }
 
-    abstract void checkEffective(Current<QName, NotificationStatement> stmt);
+    @Override
+    public final NotificationEffectiveStatement copyEffective(final Current<QName, NotificationStatement> stmt,
+            final NotificationEffectiveStatement original) {
+        return new NotificationEffectiveStatementImpl((NotificationEffectiveStatementImpl) original,
+            EffectiveStatementMixins.historyAndStatusFlags(stmt.history(), original.effectiveSubstatements()),
+            stmt.wrapSchemaPath());
+    }
 }
\ No newline at end of file