Merge "Use stream for AND evaluation"

This commit is contained in:
Khaled Abdelmohsen
2019-10-11 17:43:00 +00:00
committed by Android (Google) Code Review
2 changed files with 4 additions and 7 deletions

View File

@@ -88,11 +88,8 @@ final class RuleEvaluator {
// NOT connector has only 1 formula attached.
return !isMatch(openFormula.getFormulas().get(0), appInstallMetadata);
case AND:
boolean result = true;
for (Formula subFormula : openFormula.getFormulas()) {
result &= isMatch(subFormula, appInstallMetadata);
}
return result;
return openFormula.getFormulas().stream().allMatch(
subFormula -> isMatch(subFormula, appInstallMetadata));
default:
Slog.i(TAG, String.format("Returned no match for unknown connector %s",
openFormula.getConnector()));

View File

@@ -78,8 +78,8 @@ public final class Rule {
return false;
}
Rule that = (Rule) o;
return mFormula.equals(that.mFormula)
&& mEffect == that.mEffect;
return Objects.equals(mFormula, that.mFormula)
&& Objects.equals(mEffect, that.mEffect);
}
@Override