public static Pattern concatenate(final Collection<?> requiredValues, final boolean caseInsensitive) {
        val pattern = requiredValues
            .stream()
            .map(Object::toString)
            .collect(Collectors.joining("|", "(", ")"));
        return createPattern(pattern, caseInsensitive ? Pattern.CASE_INSENSITIVE : 0);
    }
Concatenate all elements in the given collection to form a regex pattern.

@param requiredValues  the required values
@param caseInsensitive the case insensitive
@return the pattern
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/RegexUtils.java