Source:
int evaluate(BundlePermissions bundlePermissions, Permission permission) { if (bundlePermissions == null) { return ABSTAIN; } EvaluationCacheKey evaluationCacheKey = new EvaluationCacheKey(bundlePermissions, permission); if (isEmpty()) { evaluationCache.put(evaluationCacheKey, ABSTAIN); return ABSTAIN; } Integer result = evaluationCache.get(evaluationCacheKey); boolean hasMutable = false; if (result != null) { hasMutable = (result & MUTABLE) == MUTABLE; if (!hasMutable) { return result; } } boolean postponed = false; Decision[] results = new Decision[rows.length]; int immediateDecisionIdx = -1; for (int i = 0; i < rows.length && immediateDecisionIdx == -1; i++) { if (result == null) { hasMutable = checkMutable(bundlePermissions, evaluationCacheKey, rows[i]); } try { results[i] = rows[i].evaluate(bundlePermissions, permission); } catch (Exception e) { results[i] = SecurityRow.DECISION_ABSTAIN; } if ((results[i].decision & ABSTAIN) == ABSTAIN) continue; if ((results[i].decision & POSTPONED) == POSTPONED) { postponed = true; continue; } if (!postponed) { if (!hasMutable) { evaluationCache.put(evaluationCacheKey, results[i].decision); } return results[i].decision; } immediateDecisionIdx = i; } Integer immediateDecision = handlePostponedConditions(evaluationCacheKey, hasMutable, postponed, results, immediateDecisionIdx); if (immediateDecision != null) return immediateDecision; int finalDecision = postponed ? POSTPONED : ABSTAIN; if (!hasMutable && (finalDecision & POSTPONED) != POSTPONED) { evaluationCache.put(evaluationCacheKey, finalDecision); } return finalDecision; }

Target:
int evaluate(BundlePermissions bundlePermissions, Permission permission) { if (bundlePermissions == null) { return ABSTAIN; } EvaluationCacheKey evaluationCacheKey = new EvaluationCacheKey(bundlePermissions, permission); if (isEmpty()) { evaluationCache.put(evaluationCacheKey, ABSTAIN); return ABSTAIN; } Integer result = evaluationCache.get(evaluationCacheKey); boolean hasMutable = false; if (result != null) { hasMutable = (result & MUTABLE) == MUTABLE; if (!hasMutable) { return result; } } boolean postponed = false; Decision[] results = new Decision[rows.length]; int immediateDecisionIdx = -1; for (int i = 0; i < rows.length && immediateDecisionIdx == -1; i++) { if (result == null) { hasMutable |= checkMutable(bundlePermissions, evaluationCacheKey, rows[i]); } try { results[i] = rows[i].evaluate(bundlePermissions, permission); } catch (Exception e) { results[i] = SecurityRow.DECISION_ABSTAIN; } if ((results[i].decision & ABSTAIN) == ABSTAIN) continue; if ((results[i].decision & POSTPONED) == POSTPONED) { postponed = true; continue; } if (!postponed) { if (!hasMutable) { evaluationCache.put(evaluationCacheKey, results[i].decision); } return results[i].decision; } immediateDecisionIdx = i; } Integer immediateDecision = handlePostponedConditions(evaluationCacheKey, hasMutable, postponed, results, immediateDecisionIdx); if (immediateDecision != null) return immediateDecision; int finalDecision = postponed ? POSTPONED : ABSTAIN; if (!hasMutable && (finalDecision & POSTPONED) != POSTPONED) { evaluationCache.put(evaluationCacheKey, finalDecision); } return finalDecision; }