def METHOD_NAME(row, gap_class, gap_code, selected_gap_type, selected_gap_code):
    if selected_gap_type:
        if gap_class.slug != selected_gap_type:
            return False
        if selected_gap_code:
            gap_code = str(row.conv_factor_gap_code if selected_gap_type == ConvFactorGaps.slug
                           else row.fct_gap_code)
            return gap_code == selected_gap_code
    return True