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

ru.fix.aggregating.profiler.RegexpLabelSticker Maven / Gradle / Ivy

There is a newer version: 1.6.6
Show newest version
package ru.fix.aggregating.profiler;

import java.util.Map;
import java.util.Set;
import java.util.HashMap;
import java.util.regex.Pattern;

/**
 *
 * @author Andrey Kiselev
 */

public class RegexpLabelSticker implements LabelSticker {
    private final String tagName;
    private final Map> labelValuesWithSelectors = new HashMap<>();

    public RegexpLabelSticker(String labelName,
                              Map> labelValuesWithSelectors) {
        this.labelValuesWithSelectors.putAll(labelValuesWithSelectors);
        this.tagName = labelName;
    }

    @Override
    public Map buildLabels(String identityName){
        HashMap labels = new HashMap<>();

        for(Map.Entry> entry : labelValuesWithSelectors.entrySet()) {
             for(Pattern p : entry.getValue()) {
                 if(p.matcher(identityName).matches()) {
                     labels.put(tagName, entry.getKey());
                     return labels;
                 }
             }
         }
        return labels;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy