Rework undeclared statement definition
[yangtools.git] / parser / yang-parser-spi / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / UndeclaredStatementFactory.java
1 /*
2  * Copyright (c) 2021 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.spi.meta;
9
10 import com.google.common.annotations.Beta;
11 import java.util.stream.Stream;
12 import org.eclipse.jdt.annotation.NonNull;
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.parser.spi.meta.EffectiveStmtCtx.Current;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.UndeclaredCurrent;
17
18 /**
19  * An entity capable of creating undeclared {@link EffectiveStatement} instances for a particular type. Unlike
20  * {@link StatementFactory}, effective statements created through this interface are expected to return a {@code null}
21  * from {@link EffectiveStatement#getDeclared()}.
22  *
23  * @param <A> Argument type
24  * @param <D> Declared Statement representation
25  * @param <E> Effective Statement representation
26  */
27 @Beta
28 public interface UndeclaredStatementFactory<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> {
29     /**
30      * Create a {@link EffectiveStatement} for specified context. Implementations of this method must not access
31      * {@link Current#declared()} or {@link Current#rawArgument()}.
32      *
33      * @param stmt Effective capture of this statement's significant state
34      * @param effectiveSubstatements effectively-visible substatements
35      * @return An effective statement instance
36      */
37     @NonNull E createUndeclaredEffective(@NonNull UndeclaredCurrent<A, D> stmt,
38         @NonNull Stream<? extends StmtContext<?, ?, ?>> effectiveSubstatements);
39 }