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

org.iris_events.asyncapi.api.util.ConfigUtil Maven / Gradle / Ivy

There is a newer version: 6.1.8
Show newest version
package org.iris_events.asyncapi.api.util;

import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class ConfigUtil {
    private ConfigUtil() {
    }

    public static Set asCsvSet(String items) {
        Set rval = new HashSet<>();
        if (items != null) {
            String[] split = items.split(",");
            for (String item : split) {
                rval.add(item.trim());
            }
        }
        return rval;
    }

    public static Pattern patternFromSet(Set set) {
        if (set == null || set.isEmpty()) {
            return Pattern.compile("");
        }
        return Pattern.compile(
                "(" + set.stream().map(Pattern::quote).collect(Collectors.joining("|")) + ")");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy