Add BaseSchemaTreeStatementSupport.parseArgumentValue()
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / notification / AbstractNotificationStatementSupport.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.notification;
9
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.stmt.BaseSchemaTreeStatementSupport;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19
20 abstract class AbstractNotificationStatementSupport
21         extends BaseSchemaTreeStatementSupport<NotificationStatement, NotificationEffectiveStatement> {
22     AbstractNotificationStatementSupport() {
23         super(YangStmtMapping.NOTIFICATION);
24     }
25
26     @Override
27     protected final NotificationStatement createDeclared(final StmtContext<QName, NotificationStatement, ?> ctx,
28             final ImmutableList<? extends DeclaredStatement<?>> substatements) {
29         return new RegularNotificationStatement(ctx.coerceStatementArgument(), substatements);
30     }
31
32     @Override
33     protected final NotificationStatement createEmptyDeclared(final StmtContext<QName, NotificationStatement, ?> ctx) {
34         return new EmptyNotificationStatement(ctx.coerceStatementArgument());
35     }
36
37     @Override
38     protected final NotificationEffectiveStatement createEffective(
39             final StmtContext<QName, NotificationStatement, NotificationEffectiveStatement> ctx,
40             final NotificationStatement declared,
41             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
42         checkEffective(ctx);
43
44         return new NotificationEffectiveStatementImpl(declared, historyAndStatusFlags(ctx, substatements), ctx,
45             substatements);
46     }
47
48     @Override
49     protected final NotificationEffectiveStatement createEmptyEffective(
50             final StmtContext<QName, NotificationStatement, NotificationEffectiveStatement> ctx,
51             final NotificationStatement declared) {
52         return createEffective(ctx, declared, ImmutableList.of());
53     }
54
55     abstract void checkEffective(StmtContext<QName, NotificationStatement, NotificationEffectiveStatement> ctx);
56 }