Add BaseQNameStatementSupport.historyAndStatusFlags()
[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.parser.spi.meta.StmtContext;
18
19 /**
20  * Specialization of {@link BaseQNameStatementSupport} for {@code input} and {@code output} statements.
21  *
22  * @param <D> Declared Statement representation
23  * @param <E> Effective Statement representation
24  */
25 @Beta
26 public abstract class BaseOperationContainerStatementSupport<D extends DeclaredStatement<QName>,
27         E extends EffectiveStatement<QName, D>> extends BaseImplicitStatementSupport<D, E> {
28     protected BaseOperationContainerStatementSupport(final StatementDefinition publicDefinition) {
29         super(publicDefinition);
30     }
31
32     @Override
33     protected final @NonNull E createDeclaredEffective(final StmtContext<QName, D, E> ctx,
34             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final D declared) {
35         return createDeclaredEffective(historyAndStatusFlags(ctx, substatements), ctx, substatements, declared);
36     }
37
38     protected abstract @NonNull E createDeclaredEffective(int flags, @NonNull StmtContext<QName, D, E> ctx,
39             @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements, @NonNull D declared);
40
41     @Override
42     protected final E createUndeclaredEffective(final StmtContext<QName, D, E> ctx,
43             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
44         return createUndeclaredEffective(historyAndStatusFlags(ctx, substatements), ctx, substatements);
45     }
46
47     protected abstract @NonNull E createUndeclaredEffective(int flags, @NonNull StmtContext<QName, D, E> ctx,
48             @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements);
49 }