*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
-import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
public abstract class EffectiveStatementBase<A, D extends DeclaredStatement<A>> implements EffectiveStatement<A, D> {
- private static final Predicate<StmtContext<?, ?, ?>> IS_SUPPORTED_TO_BUILD_EFFECTIVE = new Predicate<StmtContext<?, ?, ?>>() {
- @Override
- public boolean apply(final StmtContext<?, ?, ?> input) {
- return input.isSupportedToBuildEffective();
- }
- };
-
- private static final Predicate<StmtContext<?, ?, ?>> IS_UNKNOWN_STATEMENT_CONTEXT = new Predicate<StmtContext<?, ?, ?>>() {
- @Override
- public boolean apply(final StmtContext<?, ?, ?> input) {
- return StmtContextUtils.isUnknownStatement(input);
- }
- };
-
- private static final Predicate<StatementContextBase<?, ?, ?>> ARE_FEATURES_SUPPORTED = new Predicate<StatementContextBase<?, ?, ?>>() {
-
- @Override
- public boolean apply(final StatementContextBase<?, ?, ?> input) {
- return StmtContextUtils.areFeaturesSupported(input);
- }
- };
+ private static final Predicate<StmtContext<?, ?, ?>> IS_UNKNOWN_STATEMENT_CONTEXT =
+ StmtContextUtils::isUnknownStatement;
+ private static final Predicate<StmtContext<?, ?, ?>> IS_NOT_UNKNOWN_STATEMENT_CONTEXT =
+ Predicates.not(IS_UNKNOWN_STATEMENT_CONTEXT);
private final List<? extends EffectiveStatement<?, ?>> substatements;
private final List<StatementContextBase<?, ?, ?>> unknownSubstatementsToBuild;
final Collection<StatementContextBase<?, ?, ?>> substatementsInit = new ArrayList<>();
final Collection<StatementContextBase<?, ?, ?>> 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);
substatementsInit.addAll(effectiveSubstatements);
Collection<StatementContextBase<?, ?, ?>> 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();
}
- final Function<StmtContext<?, ?, ? extends EffectiveStatement<?, ?>>, EffectiveStatement<?, ?>> buildEffective = StmtContextUtils
- .buildEffective();
- this.substatements = ImmutableList.copyOf(Collections2.transform(substatementsToBuild, buildEffective));
+ this.substatements = ImmutableList.copyOf(Collections2.transform(substatementsToBuild, StatementContextBase::buildEffective));
}
Collection<EffectiveStatement<?, ?>> getOmittedUnknownSubstatements() {
- final Function<StmtContext<?, ?, ? extends EffectiveStatement<?, ?>>, EffectiveStatement<?, ?>> buildEffective = StmtContextUtils
- .buildEffective();
- return Collections2.transform(unknownSubstatementsToBuild, buildEffective);
+ return Collections2.transform(unknownSubstatementsToBuild, StatementContextBase::buildEffective);
}
@Override