protected Map<String, List<Object>> buildImmutableAttributeMap(final Map<String, List<Object>> attributes) {
        val valueBuilder = new TreeMap<String, List<Object>>(String.CASE_INSENSITIVE_ORDER);
        val arrayPattern = Pattern.compile("\\{(.*)\\}");
        for (val attrEntry : attributes.entrySet()) {
            val key = attrEntry.getKey();
            var value = attrEntry.getValue().stream().filter(Objects::nonNull).toList();
            if (!value.isEmpty()) {
                val result = value.getFirst();
                if (result instanceof Array) {
                    LOGGER.trace("Column [{}] is classified as a SQL array", key);
                    val values = result.toString();
                    LOGGER.trace("Converting SQL array values [{}] using pattern [{}]", values, arrayPattern.pattern());
                    val matcher = arrayPattern.matcher(values);
                    if (matcher.matches()) {
                        val groups = Arrays.stream(matcher.group(1).split(",")).toList();
                        value = List.copyOf(groups);
                        LOGGER.trace("Converted SQL array values [{}]", values);
                    }
                }
            }
            LOGGER.trace("Collecting attribute [{}] with value(s) [{}]", key, value);
            valueBuilder.put(key, value);
        }
        return valueBuilder;
    }
Canonicalize simple person attributes.

@param mode the mode
@return the simple person attributes
core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/attribute/SimplePersonAttributes.java