def adaptFilter(self, lyr, inputFilter, behavior):
        """
        Adapts filter according to the selected mode
        """
        originalFilter = lyr.subsetString()
        if behavior == AssignFilterToLayersAlgorithm.ReplaceMode or originalFilter == '':
            return inputFilter
        clause = ' AND ' if behavior == AssignFilterToLayersAlgorithm.AndMode else ' OR '
        return clause.join([originalFilter, inputFilter])