Skip to content

Commit

Permalink
[java] Clean lambda usage
Browse files Browse the repository at this point in the history
  • Loading branch information
hazendaz authored and mathieucarbou committed Feb 13, 2023
1 parent 508888a commit 199d09e
Showing 1 changed file with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class AggregateLicensePolicyEnforcer {
public AggregateLicensePolicyEnforcer(final Set<LicensePolicy> policies) {
this.policies = policies;
this.defaultPolicy = new DefaultLicensePolicyEnforcer();
this.enforcers = policies.stream().map(policy -> initPolicyEnforcer(policy)).collect(Collectors.toSet());
this.enforcers = policies.stream().map(AggregateLicensePolicyEnforcer::initPolicyEnforcer).collect(Collectors.toSet());
}

/**
Expand Down Expand Up @@ -112,9 +112,7 @@ private Map<Artifact, LicensePolicyEnforcerResult> apply(final License license,
private Map<Artifact, LicensePolicyEnforcerResult> apply(final Map<License, Set<Artifact>> licenseMap, final LicensePolicyEnforcer enforcer) {
final Map<Artifact, LicensePolicyEnforcerResult> results = new HashMap<>();

licenseMap.forEach((license, artifactSet) -> {
results.putAll(apply(license, artifactSet, enforcer));
});
licenseMap.forEach((license, artifactSet) -> results.putAll(apply(license, artifactSet, enforcer)));
return results;
}

Expand All @@ -140,14 +138,10 @@ public Map<Artifact, LicensePolicyEnforcerResult> apply(final Map<License, Set<A
});

// apply approval rules, updating the map
getEnforcers(LicensePolicy.Rule.APPROVE).forEach(enforcer -> {
results.putAll(apply(licenseMap, enforcer));
});
getEnforcers(LicensePolicy.Rule.APPROVE).forEach(enforcer -> results.putAll(apply(licenseMap, enforcer)));

// apply deny rules, updating the map
getEnforcers(LicensePolicy.Rule.DENY).forEach(enforcer -> {
results.putAll(apply(licenseMap, enforcer));
});
getEnforcers(LicensePolicy.Rule.DENY).forEach(enforcer -> results.putAll(apply(licenseMap, enforcer)));

return results;
}
Expand Down

0 comments on commit 199d09e

Please sign in to comment.