Move implementation of OnStatementAdded to single class
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / BaseOperationContainerStatementSupport.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, 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;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.collect.ImmutableList;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.yang.common.QName;
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.meta.StatementDefinition;
17 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19
20 /**
21  * Specialization of {@link BaseQNameStatementSupport} for {@code input} and {@code output} statements.
22  *
23  * @param <D> Declared Statement representation
24  * @param <E> Effective Statement representation
25  */
26 @Beta
27 public abstract class BaseOperationContainerStatementSupport<D extends DeclaredStatement<QName>,
28         E extends SchemaTreeEffectiveStatement<D>> extends BaseImplicitStatementSupport<D, E> {
29     protected BaseOperationContainerStatementSupport(final StatementDefinition publicDefinition) {
30         super(publicDefinition);
31     }
32
33     @Override
34     protected final @NonNull E createDeclaredEffective(final StmtContext<QName, D, E> ctx,
35             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final D declared) {
36         return createDeclaredEffective(historyAndStatusFlags(ctx, substatements), ctx, substatements, declared);
37     }
38
39     protected abstract @NonNull E createDeclaredEffective(int flags, @NonNull StmtContext<QName, D, E> ctx,
40             @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements, @NonNull D declared);
41
42     @Override
43     protected final E createUndeclaredEffective(final StmtContext<QName, D, E> ctx,
44             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
45         return createUndeclaredEffective(historyAndStatusFlags(ctx, substatements), ctx, substatements);
46     }
47
48     protected abstract @NonNull E createUndeclaredEffective(int flags, @NonNull StmtContext<QName, D, E> ctx,
49             @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements);
50 }