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.Status;
13 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
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.api.stmt.StatusEffectiveStatement;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.namespace.ChildSchemaNodeNamespace;
20 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseQNameStatementSupport;
21 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
26 abstract class AbstractNotificationStatementSupport
27 extends BaseQNameStatementSupport<NotificationStatement, NotificationEffectiveStatement> {
28 AbstractNotificationStatementSupport() {
29 super(YangStmtMapping.NOTIFICATION);
33 public final QName parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
34 return StmtContextUtils.parseIdentifier(ctx, value);
38 public final void onStatementAdded(
39 final Mutable<QName, NotificationStatement, NotificationEffectiveStatement> stmt) {
40 stmt.coerceParentContext().addToNs(ChildSchemaNodeNamespace.class, stmt.coerceStatementArgument(), stmt);
44 protected final NotificationStatement createDeclared(final StmtContext<QName, NotificationStatement, ?> ctx,
45 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
46 return new RegularNotificationStatement(ctx.coerceStatementArgument(), substatements);
50 protected final NotificationStatement createEmptyDeclared(final StmtContext<QName, NotificationStatement, ?> ctx) {
51 return new EmptyNotificationStatement(ctx.coerceStatementArgument());
55 protected final NotificationEffectiveStatement createEffective(
56 final StmtContext<QName, NotificationStatement, NotificationEffectiveStatement> ctx,
57 final NotificationStatement declared,
58 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
61 final int flags = new FlagsBuilder()
62 .setHistory(ctx.getCopyHistory())
63 .setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
66 return new NotificationEffectiveStatementImpl(declared, flags, ctx, substatements);
70 protected final NotificationEffectiveStatement createEmptyEffective(
71 final StmtContext<QName, NotificationStatement, NotificationEffectiveStatement> ctx,
72 final NotificationStatement declared) {
73 return createEffective(ctx, declared, ImmutableList.of());
76 abstract void checkEffective(StmtContext<QName, NotificationStatement, NotificationEffectiveStatement> ctx);