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=7f55295465c586afec4228f49cc0ee55cf66480e;hb=f6eae2a11c570c1097eb9202debc7e36ce72ef6d;hp=7151db18f4c37124fc925074a37ddb331297b2cd;hpb=387d6385bbd6a689372c6ac9cdde4021a7162e4d;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 7151db18f4..7f55295465 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
@@ -28,21 +28,10 @@ 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> IS_UNKNOWN_STATEMENT_CONTEXT =
+ StmtContextUtils::isUnknownStatement;
+ private static final Predicate> IS_NOT_UNKNOWN_STATEMENT_CONTEXT =
+ Predicates.not(IS_UNKNOWN_STATEMENT_CONTEXT);
private final List extends EffectiveStatement, ?>> substatements;
private final List> unknownSubstatementsToBuild;
@@ -63,12 +52,14 @@ public abstract class EffectiveStatementBase>
* method. The main purpose of this is to allow the build of
* recursive extension definitions.
*/
- protected EffectiveStatementBase(final StmtContext ctx, boolean buildUnknownSubstatements) {
+ protected EffectiveStatementBase(final StmtContext ctx, final boolean buildUnknownSubstatements) {
final Collection> effectiveSubstatements = ctx.effectiveSubstatements();
final Collection> substatementsInit = new ArrayList<>();
- for(StatementContextBase, ?, ?> declaredSubstatement : ctx.declaredSubstatements()) {
+ final Collection> supportedDeclaredSubStmts = Collections2.filter(
+ ctx.declaredSubstatements(), StmtContextUtils::areFeaturesSupported);
+ for (final StatementContextBase, ?, ?> declaredSubstatement : supportedDeclaredSubStmts) {
if (declaredSubstatement.getPublicDefinition().equals(Rfc6020Mapping.USES)) {
substatementsInit.add(declaredSubstatement);
substatementsInit.addAll(declaredSubstatement.getEffectOfStatement());
@@ -81,23 +72,20 @@ public abstract class EffectiveStatementBase>
substatementsInit.addAll(effectiveSubstatements);
Collection> substatementsToBuild = Collections2.filter(substatementsInit,
- IS_SUPPORTED_TO_BUILD_EFFECTIVE);
+ StmtContext::isSupportedToBuildEffective);
if (!buildUnknownSubstatements) {
this.unknownSubstatementsToBuild = ImmutableList.copyOf(Collections2.filter(substatementsToBuild,
IS_UNKNOWN_STATEMENT_CONTEXT));
- substatementsToBuild = Collections2.filter(substatementsToBuild,
- Predicates.not(IS_UNKNOWN_STATEMENT_CONTEXT));
+ substatementsToBuild = Collections2.filter(substatementsToBuild, IS_NOT_UNKNOWN_STATEMENT_CONTEXT);
} else {
this.unknownSubstatementsToBuild = ImmutableList.of();
}
- this.substatements = ImmutableList.copyOf(Collections2.transform(substatementsToBuild,
- StmtContextUtils.buildEffective()));
+ this.substatements = ImmutableList.copyOf(Collections2.transform(substatementsToBuild, StatementContextBase::buildEffective));
}
Collection> getOmittedUnknownSubstatements() {
- return Collections2.transform(unknownSubstatementsToBuild,
- StmtContextUtils.buildEffective());
+ return Collections2.transform(unknownSubstatementsToBuild, StatementContextBase::buildEffective);
}
@Override
@@ -120,13 +108,13 @@ public abstract class EffectiveStatementBase>
}
protected final > S firstEffective(final Class type) {
- Optional extends EffectiveStatement, ?>> possible = Iterables.tryFind(substatements,
+ final Optional extends EffectiveStatement, ?>> possible = Iterables.tryFind(substatements,
Predicates.instanceOf(type));
return possible.isPresent() ? type.cast(possible.get()) : null;
}
protected final S firstSchemaNode(final Class type) {
- Optional extends EffectiveStatement, ?>> possible = Iterables.tryFind(substatements,
+ final Optional extends EffectiveStatement, ?>> possible = Iterables.tryFind(substatements,
Predicates.instanceOf(type));
return possible.isPresent() ? type.cast(possible.get()) : null;
}
@@ -137,13 +125,13 @@ public abstract class EffectiveStatementBase>
}
protected final T firstSubstatementOfType(final Class type) {
- Optional extends EffectiveStatement, ?>> possible = Iterables.tryFind(substatements,
+ final Optional extends EffectiveStatement, ?>> possible = Iterables.tryFind(substatements,
Predicates.instanceOf(type));
return possible.isPresent() ? type.cast(possible.get()) : null;
}
protected final R firstSubstatementOfType(final Class> type, final Class returnType) {
- Optional extends EffectiveStatement, ?>> possible = Iterables.tryFind(substatements,
+ final Optional extends EffectiveStatement, ?>> possible = Iterables.tryFind(substatements,
Predicates.and(Predicates.instanceOf(type), Predicates.instanceOf(returnType)));
return possible.isPresent() ? returnType.cast(possible.get()) : null;
}