2 * Copyright (c) 2015 Cisco Systems, Inc. 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.spi.meta;
10 import java.util.Collection;
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;
18 * An entity capable of creating {@link DeclaredStatement} and {@link EffectiveStatement} instances for a particular
19 * type. This interface is usually realized as an implementation-specific combination with {@link StatementSupport}.
21 * @param <A> Argument type
22 * @param <D> Declared Statement representation
23 * @param <E> Effective Statement representation
25 public interface StatementFactory<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> {
27 * Create a {@link DeclaredStatement} for specified context.
29 * @param ctx Statement context
30 * @return A declared statement instance.
32 @NonNull D createDeclared(@NonNull StmtContext<A, D, ?> ctx);
35 * Create a {@link EffectiveStatement} for specified context.
37 * @param stmt Effective capture of this statement's significant state
38 * @return An effective statement instance
40 @NonNull E createEffective(EffectiveStmtCtx.@NonNull Current<A, D> stmt,
41 Stream<? extends StmtContext<?, ?, ?>> declaredSubstatements,
42 Stream<? extends StmtContext<?, ?, ?>> effectiveSubstatements);
45 * Determine reactor copy behaviour of a statement instance. Implementations classes are required to determine
46 * their operations with regard to their statements being replicated into different contexts -- potentially sharing
50 * Implementations are examine {@code copy} as to whether it would result in the same semantics as {@code current}
51 * does, provided that {@code current}'s {@code substatements} are properly propagated.
53 * @param copy Copy of current effective context
54 * @param current Current effective context
55 * @param substatements Current effective substatements
56 * @return True if the differences between {@code copy} and {@code current} do not affect this statement's effective
59 boolean canReuseCurrent(@NonNull Current<A, D> copy, @NonNull Current<A, D> current,
60 @NonNull Collection<? extends EffectiveStatement<?, ?>> substatements);