private void applyCriteria(List<String> requiredContents,
            List<APISortPredicate> sortPredicates) throws GuacamoleException {

        // Restrict to records which contain the specified strings
        for (String required : requiredContents) {
            if (!required.isEmpty())
                history = history.contains(required);
        }

        // Sort according to specified ordering
        for (APISortPredicate predicate : sortPredicates)
            history = history.sort(predicate.getProperty(), predicate.isDescending());

        // Limit to maximum result size
        history = history.limit(MAXIMUM_HISTORY_SIZE);

    }
Applies the given search and sorting criteria to the ActivityRecordSet
exposed by this ActivityRecordSetResource. The ActivityRecordSet stored
as {@link #history} is modified as a result of this call.

@param requiredContents
    The set of strings that each must occur somewhere within the
    returned records, whether within the associated username,
    the name of some associated object (such as a connection), or any
    associated date. If non-empty, any record not matching each of the
    strings within the collection will be excluded from the results.

@param sortPredicates
    A list of predicates to apply while sorting the resulting records,
    describing the properties involved and the sort order for those
    properties.

@throws GuacamoleException
    If an error occurs while applying the given filter criteria or
    sort predicates.
guacamole/src/main/java/org/apache/guacamole/rest/history/ActivityRecordSetResource.java