2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.notification;
10 import com.google.common.collect.ImmutableList;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
13 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
14 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
15 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement;
18 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatementDecorators;
19 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
20 import org.opendaylight.yangtools.yang.model.ri.stmt.EffectiveStatements;
21 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins;
22 import org.opendaylight.yangtools.yang.model.spi.meta.SubstatementIndexingException;
23 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractSchemaTreeStatementSupport;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
26 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
27 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
29 abstract class AbstractNotificationStatementSupport
30 extends AbstractSchemaTreeStatementSupport<NotificationStatement, NotificationEffectiveStatement> {
31 AbstractNotificationStatementSupport(final YangParserConfiguration config) {
32 super(YangStmtMapping.NOTIFICATION, uninstantiatedPolicy(), config);
36 protected final NotificationStatement createDeclared(final StmtContext<QName, NotificationStatement, ?> ctx,
37 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
38 return DeclaredStatements.createNotification(ctx.getArgument(), substatements);
42 protected final NotificationStatement attachDeclarationReference(final NotificationStatement stmt,
43 final DeclarationReference reference) {
44 return DeclaredStatementDecorators.decorateNotification(stmt, reference);
48 protected final NotificationEffectiveStatement createEffective(final Current<QName, NotificationStatement> stmt,
49 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
51 return EffectiveStatements.createNotification(stmt.declared(), stmt.effectivePath(),
52 EffectiveStatementMixins.historyAndStatusFlags(stmt.history(), substatements), substatements);
53 } catch (SubstatementIndexingException e) {
54 throw new SourceException(e.getMessage(), stmt, e);
59 // FIXME: propagate original?
60 public final NotificationEffectiveStatement copyEffective(final Current<QName, NotificationStatement> stmt,
61 final NotificationEffectiveStatement original) {
62 return EffectiveStatements.copyNotification(original, stmt.effectivePath(),
63 EffectiveStatementMixins.historyAndStatusFlags(stmt.history(), original.effectiveSubstatements()));