X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Frfc6020%2Feffective%2FEffectiveStatementBase.java;h=81374085f66da0ad9974985f5a67af9c506681c5;hb=91f43b1ce6453fef9e04e6673e7637fb5dba8b38;hp=7794efefadc60191c081ef49ad22cccfbc66928e;hpb=29596dac02aa54e632490709bc065607ac7468d7;p=yangtools.git
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java
index 7794efefad..81374085f6 100644
--- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java
+++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java
@@ -8,7 +8,6 @@
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
@@ -27,55 +26,21 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
public abstract class EffectiveStatementBase> implements EffectiveStatement {
-
- private static final Predicate> IS_SUPPORTED_TO_BUILD_EFFECTIVE = new Predicate>() {
- @Override
- public boolean apply(final StmtContext, ?, ?> input) {
- return input.isSupportedToBuildEffective();
- }
- };
-
- private static final Predicate> IS_UNKNOWN_STATEMENT_CONTEXT = new Predicate>() {
- @Override
- public boolean apply(final StmtContext, ?, ?> input) {
- return StmtContextUtils.isUnknownStatement(input);
- }
- };
-
- private static final Predicate> ARE_FEATURES_SUPPORTED = new Predicate>() {
-
- @Override
- public boolean apply(final StatementContextBase, ?, ?> input) {
- return StmtContextUtils.areFeaturesSupported(input);
- }
- };
-
private final List extends EffectiveStatement, ?>> substatements;
- private final List> unknownSubstatementsToBuild;
-
- protected EffectiveStatementBase(final StmtContext ctx) {
- this(ctx, true);
- }
/**
* Constructor.
*
* @param ctx
* context of statement.
- * @param buildUnknownSubstatements
- * if it is false, the unknown substatements are omitted from
- * build of effective substatements till the call of either
- * effectiveSubstatements or getOmittedUnknownSubstatements
- * method. The main purpose of this is to allow the build of
- * recursive extension definitions.
*/
- protected EffectiveStatementBase(final StmtContext ctx, final boolean buildUnknownSubstatements) {
+ protected EffectiveStatementBase(final StmtContext ctx) {
final Collection> effectiveSubstatements = ctx.effectiveSubstatements();
final Collection> substatementsInit = new ArrayList<>();
final Collection> supportedDeclaredSubStmts = Collections2.filter(
- ctx.declaredSubstatements(), ARE_FEATURES_SUPPORTED);
+ ctx.declaredSubstatements(), StmtContextUtils::areFeaturesSupported);
for (final StatementContextBase, ?, ?> declaredSubstatement : supportedDeclaredSubStmts) {
if (declaredSubstatement.getPublicDefinition().equals(Rfc6020Mapping.USES)) {
substatementsInit.add(declaredSubstatement);
@@ -88,22 +53,8 @@ public abstract class EffectiveStatementBase>
}
substatementsInit.addAll(effectiveSubstatements);
- Collection> substatementsToBuild = Collections2.filter(substatementsInit,
- IS_SUPPORTED_TO_BUILD_EFFECTIVE);
- if (!buildUnknownSubstatements) {
- this.unknownSubstatementsToBuild = ImmutableList.copyOf(Collections2.filter(substatementsToBuild,
- IS_UNKNOWN_STATEMENT_CONTEXT));
- substatementsToBuild = Collections2.filter(substatementsToBuild,
- Predicates.not(IS_UNKNOWN_STATEMENT_CONTEXT));
- } else {
- this.unknownSubstatementsToBuild = ImmutableList.of();
- }
-
- this.substatements = ImmutableList.copyOf(Collections2.transform(substatementsToBuild, StatementContextBase::buildEffective));
- }
-
- Collection> getOmittedUnknownSubstatements() {
- return Collections2.transform(unknownSubstatementsToBuild, StatementContextBase::buildEffective);
+ this.substatements = ImmutableList.copyOf(Collections2.transform(Collections2.filter(substatementsInit,
+ StmtContext::isSupportedToBuildEffective), StatementContextBase::buildEffective));
}
@Override
@@ -118,11 +69,7 @@ public abstract class EffectiveStatementBase>
@Override
public final Collection extends EffectiveStatement, ?>> effectiveSubstatements() {
- if (unknownSubstatementsToBuild.isEmpty()) {
- return substatements;
- } else {
- return ImmutableList.copyOf(Iterables.concat(substatements, getOmittedUnknownSubstatements()));
- }
+ return substatements;
}
protected final > S firstEffective(final Class type) {