All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.molgenis.data.security.aggregation.AggregateAnonymizerImpl Maven / Gradle / Ivy

There is a newer version: 8.4.5
Show newest version
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);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy