2 * Copyright (c) 2020 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.yang.parser.rfc7950.stmt;
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.Status;
15 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
16 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
18 import org.opendaylight.yangtools.yang.model.api.stmt.StatusEffectiveStatement;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
23 * Specialization of {@link BaseQNameStatementSupport} for {@code input} and {@code output} statements.
25 * @param <D> Declared Statement representation
26 * @param <E> Effective Statement representation
29 public abstract class BaseOperationContainerStatementSupport<D extends DeclaredStatement<QName>,
30 E extends EffectiveStatement<QName, D>> extends BaseImplicitStatementSupport<D, E> {
31 protected BaseOperationContainerStatementSupport(final StatementDefinition publicDefinition) {
32 super(publicDefinition);
36 protected final @NonNull E createDeclaredEffective(final StmtContext<QName, D, E> ctx,
37 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements, final D declared) {
38 return createDeclaredEffective(computeFlags(ctx, substatements), ctx, substatements, declared);
41 protected abstract @NonNull E createDeclaredEffective(int flags, @NonNull StmtContext<QName, D, E> ctx,
42 @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements, @NonNull D declared);
45 protected final E createUndeclaredEffective(final StmtContext<QName, D, E> ctx,
46 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
47 return createUndeclaredEffective(computeFlags(ctx, substatements), ctx, substatements);
50 protected abstract @NonNull E createUndeclaredEffective(int flags, @NonNull StmtContext<QName, D, E> ctx,
51 @NonNull ImmutableList<? extends EffectiveStatement<?, ?>> substatements);
53 private static int computeFlags(final StmtContext<?, ?, ?> ctx,
54 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
55 return new FlagsBuilder()
56 .setHistory(ctx.getCopyHistory())
57 .setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))