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

com.coreoz.plume.admin.RegexBuilder Maven / Gradle / Ivy

The newest version!
package com.coreoz.plume.admin;

import java.util.List;

class RegexBuilder {
    private RegexBuilder() {
        // Empty constructor
    }

    static String buildHidingFieldsRegex(List keysToHide) {
        String regexKeys = keysToHide.stream()
            .reduce("", (currentRegex, element) -> {
                if (!currentRegex.isEmpty()) {
                    return currentRegex + "|(?<=\"" + element + "\":\")";
                }
                return "(?<=\"" + element + "\":\")";
            });

        if (!regexKeys.isEmpty()) {
            return "(" + regexKeys + ").*?(?=\")";
        }

        return "";
    }

    static String buildFilterUrlsRegex(List urlRegexList) {
        return urlRegexList.stream()
            .reduce("", (currentRegex, element) -> {
                if (currentRegex.isEmpty()) {
                    return "(" + element + ")";
                }
                return currentRegex + "|(" + element + ")";
            });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy