X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-spi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fspi%2Fmeta%2FAbstractStatementSupport.java;h=694a91860e71fef36358bd3552d5859dfd82bde7;hb=485db12bb79d299e44957dc66d96f23e1239c857;hp=de120775d3191a86178159ebedbbe9dc9125304b;hpb=4335e0275cf96773318caebba42d1b95cec82912;p=yangtools.git diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStatementSupport.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStatementSupport.java index de120775d3..694a91860e 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStatementSupport.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStatementSupport.java @@ -34,11 +34,6 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current; @Beta public abstract class AbstractStatementSupport, E extends EffectiveStatement> extends StatementSupport { - @Deprecated - protected AbstractStatementSupport(final StatementDefinition publicDefinition, final CopyPolicy copyPolicy) { - super(publicDefinition, copyPolicy); - } - protected AbstractStatementSupport(final StatementDefinition publicDefinition, final StatementPolicy policy) { super(publicDefinition, policy); } @@ -59,16 +54,22 @@ public abstract class AbstractStatementSupport @Override public E createEffective(final Current stmt, final Stream> declaredSubstatements, - final Stream> effectiveSubstatements) { + final Stream> inferredSubstatements) { final ImmutableList> substatements = buildEffectiveSubstatements(stmt, statementsToBuild(stmt, - declaredSubstatements(declaredSubstatements, effectiveSubstatements))); + declaredSubstatements(declaredSubstatements, inferredSubstatements))); return createEffective(stmt, substatements); } protected abstract @NonNull E createEffective(@NonNull Current stmt, @NonNull ImmutableList> substatements); + @Override + public E copyEffective(final Current stmt, final E original) { + // Most implementations are only interested in substatements. copyOf() here should be a no-op + return createEffective(stmt, ImmutableList.copyOf(original.effectiveSubstatements())); + } + /** * Give statement support a hook to transform statement contexts before they are built. Default implementation * does nothing, but note {@code augment} statement performs a real transformation. @@ -84,7 +85,7 @@ public abstract class AbstractStatementSupport // FIXME: add documentation public static final > @Nullable E findFirstStatement( - final ImmutableList> statements, final Class type) { + final Collection> statements, final Class type) { for (EffectiveStatement stmt : statements) { if (type.isInstance(stmt)) { return type.cast(stmt); @@ -95,7 +96,7 @@ public abstract class AbstractStatementSupport // FIXME: add documentation public static final > A findFirstArgument( - final ImmutableList> statements, final Class<@NonNull E> type, + final Collection> statements, final Class<@NonNull E> type, final A defValue) { final @Nullable E stmt = findFirstStatement(statements, type); return stmt != null ? stmt.argument() : defValue; @@ -111,15 +112,7 @@ public abstract class AbstractStatementSupport */ protected @NonNull ImmutableList> buildEffectiveSubstatements( final Current stmt, final List> substatements) { - return defaultBuildEffectiveSubstatements(substatements); - } - - private static @NonNull ImmutableList> defaultBuildEffectiveSubstatements( - final List> substatements) { - return substatements.stream() - .filter(StmtContext::isSupportedToBuildEffective) - .map(StmtContext::buildEffective) - .collect(ImmutableList.toImmutableList()); + return substatements.stream().map(StmtContext::buildEffective).collect(ImmutableList.toImmutableList()); } private static @NonNull List> declaredSubstatements(