a4a597383a32228adc9bd590a96aed5f0fd4edfa
[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.EffectiveStmtCtx.Current;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
20
21 abstract class AbstractNotificationStatementSupport
22         extends BaseSchemaTreeStatementSupport<NotificationStatement, NotificationEffectiveStatement> {
23     AbstractNotificationStatementSupport() {
24         super(YangStmtMapping.NOTIFICATION);
25     }
26
27     @Override
28     protected final NotificationStatement createDeclared(final StmtContext<QName, NotificationStatement, ?> ctx,
29             final ImmutableList<? extends DeclaredStatement<?>> substatements) {
30         return new RegularNotificationStatement(ctx.getArgument(), substatements);
31     }
32
33     @Override
34     protected final NotificationStatement createEmptyDeclared(final StmtContext<QName, NotificationStatement, ?> ctx) {
35         return new EmptyNotificationStatement(ctx.getArgument());
36     }
37
38     @Override
39     protected final NotificationEffectiveStatement createEffective(final Current<QName, NotificationStatement> stmt,
40             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
41         checkEffective(stmt);
42
43         return new NotificationEffectiveStatementImpl(stmt.declared(), substatements, stmt.sourceReference(),
44                 historyAndStatusFlags(stmt.history(), substatements), stmt.getSchemaPath());
45     }
46
47     abstract void checkEffective(Current<QName, NotificationStatement> stmt);
48 }