protected final QB generateQuery(final Map<String, List<Object>> query) {
        QB queryBuilder = null;

        if (queryAttributeMapping != null && !queryAttributeMapping.isEmpty()) {
            for (val queryAttrEntry : queryAttributeMapping.entrySet()) {
                var queryAttr = queryAttrEntry.getKey();
                var queryValues = query.get(queryAttr);
                if (queryValues != null) {
                    val dataAttributes = queryAttrEntry.getValue();
                    if (dataAttributes == null) {
                        queryBuilder = appendCanonicalizedAttributeToQuery(queryBuilder, queryAttr, null, queryValues);
                    } else {
                        for (val dataAttribute : dataAttributes) {
                            queryBuilder = appendCanonicalizedAttributeToQuery(queryBuilder, queryAttr, dataAttribute, queryValues);
                        }
                    }
                } else if (requireAllQueryAttributes) {
                    LOGGER.debug("Query [{}] does not contain all attributes as specified in [{}]", query, queryAttributeMapping);
                    return null;
                }
            }
        } else if (useAllQueryAttributes) {
            for (val queryAttrEntry : query.entrySet()) {
                val queryKey = queryAttrEntry.getKey();
                val queryValues = queryAttrEntry.getValue();
                queryBuilder = appendCanonicalizedAttributeToQuery(queryBuilder, queryKey, queryKey, queryValues);
            }
        }

        queryBuilder = finalizeQueryBuilder(queryBuilder, query);
        LOGGER.debug("Generated query builder [{}] from query Map [{}]", queryBuilder, query);
        return queryBuilder;
    }
Generates a query using the queryBuilder object passed by the subclass. Attribute/Value pairs are added to the
queryBuilder by calling {@link #appendCanonicalizedAttributeToQuery(Object, String, String, List)} which calls
{@link #appendAttributeToQuery(Object, String, List)}. Attributes are only added if
there is an attributed mapped in the queryAttributeMapping.

@param query The query Map to populate the queryBuilder with.
@return The fully populated query builder.
core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/attribute/AbstractQueryPersonAttributeDao.java