2 * Copyright (c) 2021 PANTHEON.tech, 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.rfc8639.parser;
10 import com.google.common.collect.ImmutableList;
11 import org.opendaylight.yangtools.rfc8639.model.api.SubscribedNotificationsStatements;
12 import org.opendaylight.yangtools.rfc8639.model.api.SubscriptionStateNotificationEffectiveStatement;
13 import org.opendaylight.yangtools.rfc8639.model.api.SubscriptionStateNotificationStatement;
14 import org.opendaylight.yangtools.yang.common.Empty;
15 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
16 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
17 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
18 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
19 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractEmptyStatementSupport;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
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.SubstatementValidator;
25 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
27 public final class SubscriptionStateNotificationStatementSupport
28 extends AbstractEmptyStatementSupport<SubscriptionStateNotificationStatement,
29 SubscriptionStateNotificationEffectiveStatement> {
30 private static final SubstatementValidator VALIDATOR =
31 SubstatementValidator.builder(SubscribedNotificationsStatements.SUBSCRIPTION_STATE_NOTIFICATION).build();
33 public SubscriptionStateNotificationStatementSupport(final YangParserConfiguration config) {
34 super(SubscribedNotificationsStatements.SUBSCRIPTION_STATE_NOTIFICATION, StatementPolicy.exactReplica(),
39 public void onStatementAdded(final Mutable<Empty, SubscriptionStateNotificationStatement,
40 SubscriptionStateNotificationEffectiveStatement> stmt) {
41 SourceException.throwIf(YangStmtMapping.NOTIFICATION != stmt.coerceParentContext().publicDefinition(), stmt,
42 "Only notifications may be marked with subscription-state-notification");
46 protected SubscriptionStateNotificationStatement createDeclared(
47 final StmtContext<Empty, SubscriptionStateNotificationStatement, ?> ctx,
48 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
49 return new SubscriptionStateNotificationStatementImpl(substatements);
53 protected SubscriptionStateNotificationStatement attachDeclarationReference(
54 final SubscriptionStateNotificationStatement stmt, final DeclarationReference reference) {
55 return new RefSubscriptionStateNotificationStatement(stmt, reference);
59 protected SubscriptionStateNotificationEffectiveStatement createEffective(
60 final Current<Empty, SubscriptionStateNotificationStatement> stmt,
61 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
62 return new SubscriptionStateNotificationEffectiveStatementImpl(stmt.declared(), substatements);