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.DeclaredStatement;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationEffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement;
17 import org.opendaylight.yangtools.yang.parser.rfc7950.namespace.ChildSchemaNodeNamespace;
18 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseQNameStatementSupport;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
23 abstract class AbstractNotificationStatementSupport
24 extends BaseQNameStatementSupport<NotificationStatement, NotificationEffectiveStatement> {
25 AbstractNotificationStatementSupport() {
26 super(YangStmtMapping.NOTIFICATION);
30 public final QName parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
31 return StmtContextUtils.parseIdentifier(ctx, value);
35 public final void onStatementAdded(
36 final Mutable<QName, NotificationStatement, NotificationEffectiveStatement> stmt) {
37 stmt.coerceParentContext().addToNs(ChildSchemaNodeNamespace.class, stmt.coerceStatementArgument(), stmt);
41 protected final NotificationStatement createDeclared(final StmtContext<QName, NotificationStatement, ?> ctx,
42 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
43 return new RegularNotificationStatement(ctx.coerceStatementArgument(), substatements);
47 protected final NotificationStatement createEmptyDeclared(final StmtContext<QName, NotificationStatement, ?> ctx) {
48 return new EmptyNotificationStatement(ctx.coerceStatementArgument());
52 protected final NotificationEffectiveStatement createEffective(
53 final StmtContext<QName, NotificationStatement, NotificationEffectiveStatement> ctx,
54 final NotificationStatement declared,
55 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
58 return new NotificationEffectiveStatementImpl(declared, historyAndStatusFlags(ctx, substatements), ctx,
63 protected final NotificationEffectiveStatement createEmptyEffective(
64 final StmtContext<QName, NotificationStatement, NotificationEffectiveStatement> ctx,
65 final NotificationStatement declared) {
66 return createEffective(ctx, declared, ImmutableList.of());
69 abstract void checkEffective(StmtContext<QName, NotificationStatement, NotificationEffectiveStatement> ctx);