org.molgenis.data.security.aggregation.AggregateAnonymizerImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of molgenis-data-security Show documentation
Show all versions of molgenis-data-security Show documentation
Security data model and data layer security.
package org.molgenis.data.security.aggregation;
import com.google.common.collect.Lists;
import java.util.List;
import org.molgenis.data.aggregation.AggregateResult;
import org.springframework.stereotype.Component;
@Component
public class AggregateAnonymizerImpl implements AggregateAnonymizer {
@Override
public AnonymizedAggregateResult anonymize(final AggregateResult result, final int threshold) {
List> anonymizedmatrix = Lists.newArrayList();
for (List row : result.getMatrix()) {
List anonymizedRow =
Lists.transform(
row,
input -> {
if (input == null) return null;
return input <= threshold
? AnonymizedAggregateResult.AGGREGATE_ANONYMIZATION_VALUE
: input;
});
anonymizedmatrix.add(anonymizedRow);
}
return new AnonymizedAggregateResult(
anonymizedmatrix, result.getxLabels(), result.getyLabels(), threshold);
}
}