class ReportConfigUtil {

    public List<LookoutMeasurement> filter(List<LookoutMeasurement> measures) {
        List<String> mnps = metricNamePrefixWhitelist;
        Map<String, String> tagFilters = tagWhitelist;
        if (mnps == null && tagFilters == null) {
            return measures;
        }
        Iterator<LookoutMeasurement> it = measures.iterator();
        while (it.hasNext()) {
            boolean included = false;
            LookoutMeasurement measurement = it.next();
            if (mnps != null) {
                for (String prefix : mnps) {
                    if (measurement.metricId().name().startsWith(prefix)) {
                        included = true;
                        break;//符合一个条件
                    }
                }
            }
            if (!included && tagFilters != null) {
                for (Map.Entry<String, String> e : tagFilters.entrySet()) {
                    if (measurement.containsTag(e.getKey())
                        && e.getValue().equals(measurement.getTags().get(e.getKey()))) {
                        included = true;
                        break;//符合一个条件
                    }
                }
            }
            if (!included) {
                it.remove();
            }
        }
        return measures;
    }

}